Skip to content

Commit

Permalink
Merged a dozen commits from 5.1, mostly fixes
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://scm.fusionforge.org/srv/svn/fusionforge/trunk@11693 9d84d37e-dcb1-4aad-b103-6f3d92f53bf6
  • Loading branch information
lolando committed Dec 3, 2010
1 parent 405e9d7 commit 1a3b94d
Show file tree
Hide file tree
Showing 43 changed files with 150 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct($id=0) {
$this->_addHook("project_admin_plugins"); // to show up in the admin page fro group
}

function CallHook ($hookname, $params) {
function CallHook ($hookname, &$params) {
global $use_soapadminplugin,$G_SESSION,$HTML;
if ($hookname == "usermenu") {
$text = $this->text; // this is what shows in the tab
Expand Down
2 changes: 1 addition & 1 deletion plugins/old/webcalendar/common/webcalendarPlugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function webcalendarPlugin () {
$this->hooks[] = "list_roles_by_permission";
}

function CallHook ($hookname, $params) {
function CallHook ($hookname, &$params) {
global $use_webcalendarplugin,$G_SESSION,$HTML;
if ($hookname == "usermenu") {
$text = $this->text; // this is what shows in the tab
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct($id=0) {
$this->_addHook("project_admin_plugins"); // to show up in the admin page fro group
}

function CallHook ($hookname, $params) {
function CallHook ($hookname, &$params) {
global $use_helloworldplugin,$G_SESSION,$HTML;
if ($hookname == "usermenu") {
$text = $this->text; // this is what shows in the tab
Expand Down
2 changes: 1 addition & 1 deletion plugins/templates/scmcpold/common/CpoldPlugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function CpoldPlugin () {
$this->register () ;
}

function CallHook ($hookname, $params) {
function CallHook ($hookname, &$params) {
global $HTML;

switch ($hookname) {
Expand Down
2 changes: 0 additions & 2 deletions src/common/forum/Forum.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,6 @@ function create($forum_name,$description,$is_public=1,$send_all_posts_to='',$cre
}
db_commit();

$this->Group->normalizeAllRoles () ;

return true;
}

Expand Down
4 changes: 3 additions & 1 deletion src/common/include/Group.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2438,6 +2438,8 @@ function approve(&$user) {
}
}

$this->normalizeAllRoles () ;

// Switch back to user preference
session_set_internal ($saved_session->getID()) ;
setup_gettext_from_context();
Expand Down Expand Up @@ -2611,7 +2613,7 @@ function sendNewProjectNotificationEmail() {
return false;
}

$admins = RBACEngine::getInstance()->getUsersByAllowedAction ('project_approve', -1) ;
$admins = RBACEngine::getInstance()->getUsersByAllowedAction ('approve_projects', -1) ;

if (count($admins) < 1) {
$this->setError(_("There is no administrator to send the mail to."));
Expand Down
2 changes: 1 addition & 1 deletion src/common/include/Plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function getPluginPath () {
* @param hookname - the "handle" of the hook
* @param params - array of parameters to pass the hook
*/
function CallHook ($hookname, $params) {
function CallHook ($hookname, &$params) {
return true ;
}

Expand Down
1 change: 1 addition & 0 deletions src/common/include/PluginManager.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ function LoadPlugin($p_name) {
}
}
unset($this->plugins_data[$p_id]);
return false ;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/include/SCMPlugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function SCMPlugin () {
# scm_update_repolist
}

function CallHook ($hookname, $params) {
function CallHook ($hookname, &$params) {
global $HTML ;

switch ($hookname) {
Expand Down
2 changes: 1 addition & 1 deletion src/common/include/User.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ function &getGroups($onlylocal = true) {
}
}
}
return group_get_objects(array_unique($ids)) ;
return group_get_objects(array_values(array_unique($ids))) ;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/common/include/config-vars.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
forge_set_config_item_bool ('user_registration_restricted', 'core') ;
forge_define_config_item ('project_registration_restricted', 'core', $GLOBALS['sys_project_reg_restricted']) ;
forge_set_config_item_bool ('project_registration_restricted', 'core') ;
forge_define_config_item ('project_auto_approval', 'core', false) ;
forge_set_config_item_bool ('project_auto_approval', 'core') ;
forge_define_config_item ('project_auto_approval_user', 'core', 'admin') ;
forge_define_config_item ('web_host', 'core', $GLOBALS['sys_default_domain']) ;
forge_define_config_item ('apache_user', 'core', $GLOBALS['sys_apache_user']) ;
forge_define_config_item ('apache_group', 'core', $GLOBALS['sys_apache_group']) ;
Expand Down
2 changes: 0 additions & 2 deletions src/common/pm/ProjectGroup.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@ function create($project_name,$description,$is_public=1,$send_all_posts_to='') {

db_commit();

$this->Group->normalizeAllRoles () ;

return true;
}

Expand Down
93 changes: 75 additions & 18 deletions src/common/tracker/Artifact.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
* TOGETHER WITH THE SOFTWARE TO WHICH THE CONTRIBUTION RELATES OR ON A STAND
* ALONE BASIS."
*/

require_once $gfcommon.'include/Error.class.php';
require_once $gfcommon.'tracker/ArtifactMessage.class.php';
require_once $gfcommon.'tracker/ArtifactExtraField.class.php';
Expand Down Expand Up @@ -179,8 +178,7 @@ function Artifact(&$ArtifactType, $data=false) {
}
}
}



/**
* create - construct a new Artifact in the database.
*
Expand All @@ -189,12 +187,14 @@ function Artifact(&$ArtifactType, $data=false) {
* @param int The ID of the user to which this artifact is to be assigned.
* @param int The artifacts priority.
* @param array Array of extra fields like: array(15=>'foobar',22=>'1');
* @param array Array of data to change submitter and time of submit like: array('user' => 127, 'time' => 1234556789)
* @return id on success / false on failure.
*/
function create( $summary, $details, $assigned_to=100, $priority=3, $extra_fields=array()) {
function create( $summary, $details, $assigned_to=100, $priority=3, $extra_fields=array(), $importData = array()) {
//
// make sure this person has permission to add artifacts
//

if (!$this->ArtifactType->isPublic()) {
//
// Only admins can post/modify private artifacts
Expand All @@ -211,16 +211,22 @@ function create( $summary, $details, $assigned_to=100, $priority=3, $extra_field
//
// get the user_id
//
if (session_loggedin()) {
$user=user_getid();

if(array_key_exists('user', $importData)){
$user = $importData['user'];
} else {
if ($this->ArtifactType->allowsAnon()) {
$user=100;
if (session_loggedin()) {
$user=user_getid();
} else {
$this->setError(_('Artifact: This ArtifactType Does Not Allow Anonymous Submissions. Please Login.'));
return false;
if ($this->ArtifactType->allowsAnon()) {
$user=100;
} else {
$this->setError(_('Artifact: This ArtifactType Does Not Allow Anonymous Submissions. Please Login.'));
return false;
}
}
}
}


//
// data validation
Expand Down Expand Up @@ -254,7 +260,11 @@ function create( $summary, $details, $assigned_to=100, $priority=3, $extra_field
}

db_begin();

if (array_key_exists('time',$importData)){
$time = $importData['time'];
} else {
$time = time();
}
$res = db_query_params ('INSERT INTO artifact
(group_artifact_id,status_id,priority,
submitted_by,assigned_to,open_date,summary,details)
Expand All @@ -264,7 +274,7 @@ function create( $summary, $details, $assigned_to=100, $priority=3, $extra_field
$priority,
$user,
$assigned_to,
time(),
$time,
htmlspecialchars($summary),
htmlspecialchars($details))) ;
if (!$res) {
Expand Down Expand Up @@ -773,21 +783,68 @@ function addMessage($body,$by=false,$send_followup=false) {
*
* @param string The name of the field in the database being modified.
* @param string The former value of this field.
* @param array Array of data to change submitter and time of submit like: array('user' => 127, 'time' => 1234556789)
* @access private
* @return boolean success.
*/
function addHistory($field_name,$old_value) {
if (!session_loggedin()) {
$user=100;
function addHistory($field_name,$old_value, $importData = array()) {
if (array_key_exists('user', $importData)){
$user = $importData['user'];
} else {
if (!session_loggedin()) {
$user=100;
} else {
$user=user_getid();
}
}
if (array_key_exists('time',$importData)){
$time = $importData['time'];
} else {
$user=user_getid();
$time = time();
}
return db_query_params ('INSERT INTO artifact_history(artifact_id,field_name,old_value,mod_by,entrydate) VALUES ($1,$2,$3,$4,$5)',
array ($this->getID(),
$field_name,
addslashes($old_value),
$user,
time())) ;
$time)) ;
}

/**
* setStatus - set the status of this artifact.
*
* @param int The artifact status ID.
* @param int Closing date if status = 1
*
* @return boolean success.
*/
function setStatus($status_id, $closingTime=False) {
db_begin();
$qpa = db_construct_qpa (false, 'UPDATE artifact SET status_id=$1', array ($status_id)) ;
if ($closingTime && $status_id != 1) {
$time=$closingTime;
$qpa = db_construct_qpa ($qpa, ', close_date=$1 ', array ($time)) ;
}
$qpa = db_construct_qpa ($qpa,
'WHERE artifact_id=$1 AND group_artifact_id=$2',
array ($this->getID(), $artifact_type_id)) ;
$result=db_query_qpa($qpa);

if (!$result || db_affected_rows($result) < 1) {
$this->setError('Error - update failed!'.db_error());
db_rollback();
return false;
} else {
if (!$this->fetchData($this->getID())) {
db_rollback();
return false;
}
}


//commiting changes
db_commit();
return true;
}

/**
Expand Down
41 changes: 22 additions & 19 deletions src/common/tracker/ArtifactFile.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ function ArtifactFile(&$Artifact, $data=false) {
* @param string Item filesize.
* @param binary Binary item data.
* @param string Item description.
* @return id on success / false on failure.
* @param array Array of data to change submitter and time of submit like: array('user' => 127, 'time' => 1234556789)
* @return id on success / false on failure.
*/
function create($filename, $filetype, $filesize, $bin_data, $description='None') {
function create($filename, $filetype, $filesize, $bin_data, $description='None', $importData = array()) {
// Some browsers don't supply mime type if they don't know it
if (!$filetype) {
// Let's be on safe side?
Expand All @@ -131,11 +132,22 @@ function create($filename, $filetype, $filesize, $bin_data, $description='None')
return false;
}

if (session_loggedin()) {
$userid=user_getid();
if (array_key_exists('user', $importData)){
$userid = $importData['user'];
} else {
$userid=100;
if (session_loggedin()) {
$userid=user_getid();
} else {
$userid=100;
}
}

if (array_key_exists('time',$importData)){
$time = $importData['time'];
} else {
$time = time();
}


// If $filetype is "text/plain", $bin_data convert UTF-8 encoding.
if (strcasecmp($filetype,"text/plain") === 0 &&
Expand All @@ -156,7 +168,7 @@ function_exists('mb_detect_encoding')) {
$filename,
$filesize,
$filetype,
time(),
$time,
$userid)) ;

$id=db_insertid($res,'artifact_file','id');
Expand All @@ -166,20 +178,11 @@ function_exists('mb_detect_encoding')) {
$this->setError('ArtifactFile: '.db_error());
return false;
} else {
/*
//
// skip this unless we need it later - save a db query
//
//
// Now set up our internal data structures
//
if (!$this->fetchData($id)) {
db_rollback();
return false;
}
*/
db_commit();
$this->Artifact->addHistory('File Added',$id.': '.$filename);
// If time is set, no need to add to history, will be done in batch
if (!array_key_exists('time', $importData)){
$this->Artifact->addHistory('File Added',$id.': '.$filename);
}
$this->Artifact->UpdateLastModifiedDate();
$this->clearError();
return $id;
Expand Down
1 change: 0 additions & 1 deletion src/common/tracker/ArtifactType.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ function create($name,$description,$is_public,$allow_anon,$email_all,$email_addr
return false;
} else {
db_commit();
$this->Group->normalizeAllRoles () ;
return $id;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function ASelectextauthPlugin () {
$this->hooks[] = "session_set_entry";
}

function CallHook ($hookname, $params) {
function CallHook ($hookname, &$params) {
global $HTML ;

switch ($hookname) {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/blocks/common/blocksPlugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function blocksPlugin () {
$this->hooks[] = "blocks"; // to show up in the admin page fro group
}

function CallHook ($hookname, $params) {
function CallHook ($hookname, &$params) {
if ($hookname == "project_admin_plugins") {
// this displays the link in the project admin options page to it's blocks administration
$group_id = $params['group_id'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function ContribTrackerPlugin () {
$this->hooks[] = "site_admin_option_hook"; // to show in the site admin page
}

function CallHook ($hookname, $params) {
function CallHook ($hookname, &$params) {
if ($hookname == "groupmenu") {
$group_id=$params['group'];
$project = &group_get_object($group_id);
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/cvssyncmail/common/CVSSyncMailPlugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function CVSSyncMailPlugin () {
$this->hooks[] = "groupisactivecheckboxpost" ; //
}

function CallHook ($hookname, $params) {
function CallHook ($hookname, &$params) {
global $use_cvssyncmailplugin,$G_SESSION,$HTML;
$group_id=$params['group'];
if ($hookname == "groupisactivecheckbox") {
Expand Down
Loading

0 comments on commit 1a3b94d

Please sign in to comment.