* @param array The result array, if it's passed in
* @return object FRSRelease object
*/
-function &frsrelease_get_object($release_id, $data=false) {
+function frsrelease_get_object($release_id, $data = false) {
global $FRSRELEASE_OBJ;
if (!isset($FRSRELEASE_OBJ['_'.$release_id.'_'])) {
if ($data) {
- //the db result handle was passed in
+ //the db result handle was passed in
} else {
$res = db_query_params ('SELECT * FROM frs_release WHERE release_id=$1',
array ($release_id)) ;
}
$data = db_fetch_array($res);
}
- $FRSPackage =& frspackage_get_object($data['package_id']);
+ $FRSPackage = frspackage_get_object($data['package_id']);
$FRSRELEASE_OBJ['_'.$release_id.'_']= new FRSRelease($FRSPackage,$data['release_id'],$data);
}
return $FRSRELEASE_OBJ['_'.$release_id.'_'];
* @param array The associative array of data.
* @return boolean success.
*/
- function FRSRelease(&$FRSPackage, $release_id=false, $arr=false) {
+ function FRSRelease(&$FRSPackage, $release_id = false, $arr = false) {
$this->Error();
if (!$FRSPackage || !is_object($FRSPackage)) {
$this->setError('FRSRelease:: No Valid FRSPackage Object');
}
/**
- * sendNotice - the logic to send an email/jabber notice for a release.
+ * sendNotice - the logic to send an email notice for a release.
*
* @return boolean success.
*/
$this->FRSPackage->getName());
$text = stripcslashes(sprintf(_('Project %1$s (%2$s) has released a new version of package "%3$s".
-Release note:
-
+Release note:
+
%4$s
-
+
Change note:
%5$s
notified in the future, please login to %7$s and click this link:
%8$s
-
-
-
+
+
+
'
),
$this->FRSPackage->Group->getPublicName(),
$this->FRSPackage->Group->getUnixName(),
- $this->FRSPackage->getName(),
+ $this->FRSPackage->getName(),
$this->getNotes(),
$this->getChanges(),
util_make_url ("/frs/?group_id=". $this->FRSPackage->Group->getID() ."&release_id=". $this->getID()),
- forge_get_config ('forge_name'),
+ forge_get_config('forge_name'),
util_make_url ("/frs/monitor.php?filemodule_id=".$this->FRSPackage->getID()."&group_id=".$this->FRSPackage->Group->getID()."&stop=1")));
// $text = util_line_wrap($text);
if (count($arr)) {
util_handle_message(array_unique($arr),$subject,$text);
}
-
+
}
/**
$this->FRSPackage->Group->getUnixName() . '/' .
$this->FRSPackage->getFileName().'/'.
$this->getFileName().'/';
-
+
// double-check we're not trying to remove root dir
if (util_is_root_dir($dir)) {
$this->setError('Release::delete error: trying to delete root dir');
return false;
}
rmdir($dir);
-
+
db_query_params ('DELETE FROM frs_release WHERE release_id=$1 AND package_id=$2',
array ($this->getID(),
$this->FRSPackage->getID())) ;
* @param int The unix date of the release.
* @return boolean success.
*/
- function update($status,$name,$notes,$changes,$preformatted,$release_date) {
+ function update($status, $name, $notes, $changes, $preformatted, $release_date) {
if (strlen($name) < 3) {
$this->setError(_('FRSPackage Name Must Be At Least 3 Characters'));
return false;
}
-
- if (!forge_check_perm ('frs', $this->FRSPackage->Group->getID(), 'write')) {
+
+ if (!forge_check_perm('frs', $this->FRSPackage->Group->getID(), 'write')) {
$this->setPermissionDeniedError();
return false;
}
} else {
$preformatted = 0;
}
-
- if($this->getName()!=htmlspecialchars($name)) {
+
+ if($this->getName() != htmlspecialchars($name)) {
$res = db_query_params ('SELECT * FROM frs_release WHERE package_id=$1 AND name=$2',
array ($this->FRSPackage->getID(),
htmlspecialchars($name))) ;
$this->setError('FRSRelease::update() Error On Update: Name Already Exists');
return false;
}
- }
+ }
db_begin();
$res = db_query_params ('UPDATE frs_release SET name=$1,status_id=$2,notes=$3,
changes=$4,preformatted=$5,release_date=$6,released_by=$7
$newfilename = $this->getFileName();
$olddirlocation = forge_get_config('upload_dir').'/'.$this->FRSPackage->Group->getUnixName().'/'.$this->FRSPackage->getFileName().'/'.$oldfilename;
$newdirlocation = forge_get_config('upload_dir').'/'.$this->FRSPackage->Group->getUnixName().'/'.$this->FRSPackage->getFileName().'/'.$newfilename;
-
+
if (($oldfilename!=$newfilename) && is_dir($olddirlocation)) {
if (is_dir($newdirlocation)) {
$this->setError('FRSRelease::update() Error Updating Release: Directory Already Exists');
db_rollback();
- return false;
+ return false;
} else {
if(!rename($olddirlocation,$newdirlocation)) {
$this->setError("FRSRelease::update() Error Updating Release: Couldn't rename dir");
return false;
}
}
- }
+ }
db_commit();
+ $this->FRSPackage->createNewestReleaseFilesAsZip();
return true;
}
*
* Copyright 1999-2001, VA Linux Systems, Inc.
* Copyright 2009-2010, Roland Mas
+ * Copyright 2011, Franck Villaume - Capgemini
+ * http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
* you can redistribute it and/or modify it under the terms of the
/**
* user_get_object_by_name() - Get User object by username.
- * user_get_object is useful so you can pool user objects/save database queries
- * You should always use this instead of instantiating the object directly
- *
- * @param string The unix username - required
- * @param int The result set handle ("SELECT * FROM USERS WHERE user_id=xx")
- * @return a user object or false on failure
+ * user_get_object is useful so you can pool user objects/save database queries
+ * You should always use this instead of instantiating the object directly
*
+ * @param string The unix username - required
+ * @param int The result set handle ("SELECT * FROM USERS WHERE user_id=xx")
+ * @return a user object or false on failure
*/
-function &user_get_object_by_name($user_name,$res=false) {
+function &user_get_object_by_name($user_name, $res = false) {
$user_name = strtolower($user_name);
if (!$res) {
- $res = db_query_params ('SELECT * FROM users WHERE user_name=$1',
- array ($user_name)) ;
+ $res = db_query_params('SELECT * FROM users WHERE user_name=$1',
+ array($user_name));
}
- return user_get_object(db_result($res,0,'user_id'),$res);
+ return user_get_object(db_result($res, 0, 'user_id'), $res);
}
/**
* user_get_object_by_email() - Get User object by email address
- * Only works if sys_require_unique_email is true
+ * Only works if sys_require_unique_email is true
*
- * @param string The unix username - required
- * @param int The result set handle ("SELECT * FROM USERS WHERE user_id=xx")
- * @return a user object or false on failure
+ * @param string The unix username - required
+ * @param int The result set handle ("SELECT * FROM USERS WHERE user_id=xx")
+ * @return a user object or false on failure
*
*/
-function user_get_object_by_email($email,$res=false) {
+function user_get_object_by_email($email ,$res = false) {
if (!validate_email($email)
|| !forge_get_config('require_unique_email')) {
- return false ;
+ return false;
}
if (!$res) {
$res=db_query_params('SELECT * FROM users WHERE email=$1',
- array ($email));
+ array($email));
}
- return user_get_object(db_result($res,0,'user_id'),$res);
+ return user_get_object(db_result($res, 0, 'user_id'), $res);
}
/**
* user_get_object() - Get User object by user ID.
- * user_get_object is useful so you can pool user objects/save database queries
- * You should always use this instead of instantiating the object directly
- *
- * @param int The ID of the user - required
- * @param int The result set handle ("SELECT * FROM USERS WHERE user_id=xx")
- * @return a user object or false on failure
+ * user_get_object is useful so you can pool user objects/save database queries
+ * You should always use this instead of instantiating the object directly
*
+ * @param int The ID of the user - required
+ * @param int The result set handle ("SELECT * FROM USERS WHERE user_id=xx")
+ * @return object a user object or false on failure
*/
-function &user_get_object($user_id,$res=false) {
+function &user_get_object($user_id, $res = false) {
//create a common set of group objects
//saves a little wear on the database
-
- //automatically checks group_type and
+
+ //automatically checks group_type and
//returns appropriate object
-
+
global $USER_OBJ;
if (!isset($USER_OBJ["_".$user_id."_"])) {
if ($res) {
//the db result handle was passed in
} else {
- $res = db_query_params ('SELECT * FROM users WHERE user_id=$1',
- array ($user_id)) ;
+ $res = db_query_params('SELECT * FROM users WHERE user_id=$1',
+ array($user_id));
}
if (!$res || db_numrows($res) < 1) {
$USER_OBJ["_".$user_id."_"]=false;
}
}
if (count($fetch) > 0) {
- $res = db_query_params ('SELECT * FROM users WHERE user_id = ANY ($1)',
- array (db_int_array_to_any_clause ($fetch))) ;
+ $res = db_query_params('SELECT * FROM users WHERE user_id = ANY ($1)',
+ array(db_int_array_to_any_clause ($fetch)));
while ($arr = db_fetch_array($res)) {
$USER_OBJ["_".$arr['user_id']."_"] = new GFUser($arr['user_id'],$arr);
}
}
function &user_get_objects_by_name($username_arr) {
- $res = db_query_params ('SELECT user_id FROM users WHERE lower(user_name) = ANY ($1)',
- array (db_string_array_to_any_clause ($username_arr))) ;
- $arr =& util_result_column_to_array($res,0);
+ $res = db_query_params('SELECT user_id FROM users WHERE lower(user_name) = ANY ($1)',
+ array(db_string_array_to_any_clause ($username_arr)));
+ $arr =& util_result_column_to_array($res, 0);
+ return user_get_objects($arr);
+}
+
+function &user_get_objects_by_email($email_arr) {
+ $res=db_query_params('SELECT user_id FROM users WHERE lower(email) = ANY ($1)',
+ array(db_string_array_to_any_clause ($email_arr)));
+ $arr =& util_result_column_to_array($res, 0);
return user_get_objects($arr);
}
function &user_get_active_users() {
- $res=db_query_params ('SELECT user_id FROM users WHERE status=$1',
- array ('A')) ;
- return user_get_objects (util_result_column_to_array($res,0)) ;
+ $res=db_query_params('SELECT user_id FROM users WHERE status=$1',
+ array('A'));
+ return user_get_objects(util_result_column_to_array($res, 0));
}
class GFUser extends Error {
- /**
+ /**
* Associative array of data from db.
*
- * @var array $data_array.
+ * @var array $data_array.
*/
var $data_array;
-
+
/**
* Is this person a site super-admin?
*
- * @var bool $is_super_user
+ * @var bool $is_super_user
*/
var $is_super_user;
/**
* Is this person the logged in user?
*
- * @var bool $is_logged_in
+ * @var bool $is_logged_in
*/
var $is_logged_in;
/**
* Array of preferences
*
- * @var array $user_pref
+ * @var array $user_pref
*/
var $user_pref;
var $theme_id;
/**
- * GFUser($id,$res) - CONSTRUCTOR - GENERALLY DON'T USE THIS
+ * GFUser($id,$res) - CONSTRUCTOR - GENERALLY DON'T USE THIS
*
- * instead use the user_get_object() function call
+ * instead use the user_get_object() function call
*
- * @param int The user_id
- * @param int The database result set OR array of data
+ * @param int The user_id
+ * @param int The database result set OR array of data
*/
- function GFUser($id=false,$res=false) {
+ function GFUser($id = false, $res = false) {
$this->Error();
if (!$id) {
//setting up an empty object
$this->data_array =& $res;
} elseif (db_numrows($res) < 1) {
//function in class we extended
- $this->setError('User Not Found');
+ $this->setError(_('User Not Found'));
$this->data_array=array();
return false;
} else {
$this->is_logged_in=false;
return true;
}
-
+
/**
* create() - Create a new user.
*
* @param string The users preferred default timezone.
* @param string The users preference for receiving site updates by email.
* @param string The users preference for receiving community updates by email.
- * @param int The ID of the language preference.
+ * @param int The ID of the language preference.
* @param string The users preferred timezone.
- * @param string The users Jabber address.
- * @param int The users Jabber preference.
+ * @param ignored (no longer used)
+ * @param ignored (no longer used)
- * @param int The users theme_id.
+ * @param int The users theme_id.
* @param string The users unix_box.
* @param string The users address.
* @param string The users address part 2.
* @param string The users title.
* @param char(2) The users ISO country_code.
* @param bool Whether to send an email or not
- * @returns The newly created user ID
+ * @param int The users preference for tooltips
+ * @returns The newly created user ID
*
*/
- function create($unix_name,$firstname,$lastname,$password1,$password2,$email,
- $mail_site,$mail_va,$language_id,$timezone,$dummy1,$dummy2,$theme_id,
- $unix_box='shell',$address='',$address2='',$phone='',$fax='',$title='',$ccode='US',$send_mail=true) {
+ function create($unix_name, $firstname, $lastname, $password1, $password2, $email,
- $mail_site, $mail_va, $language_id, $timezone, $jabber_address, $jabber_only, $theme_id,
++ $mail_site, $mail_va, $language_id, $timezone, $dummy1, $dummy2, $theme_id,
+ $unix_box = 'shell', $address = '', $address2 = '', $phone = '', $fax = '', $title = '', $ccode = 'US', $send_mail = true, $tooltips = true) {
global $SYS;
if (!$theme_id) {
$this->setError(_('You must supply a theme'));
return false;
}
if (!validate_email($email)) {
- $this->setError(_('Invalid Email Address') . $email);
+ $this->setError(_('Invalid Email Address:') .' '. $email);
return false;
}
- if ($jabber_address && !validate_email($jabber_address)) {
- $this->setError(_('Invalid Jabber Address'));
- return false;
- }
- if (!$jabber_only) {
- $jabber_only=0;
- } else {
- $jabber_only=1;
- }
if ($unix_name && db_numrows(db_query_params('SELECT user_id FROM users WHERE user_name LIKE $1',
- array ($unix_name))) > 0) {
+ array($unix_name))) > 0) {
$this->setError(_('That username already exists.'));
return false;
}
if (forge_get_config('require_unique_email')) {
- if (user_get_object_by_email ('$email')) {
+ if (user_get_object_by_email('$email')) {
$this->setError(_('User with this email already exists - use people search to recover your login.'));
return false;
}
// Let's generate a loginname for the user
// ...based on the email address:
$email_array = explode ('@', $email, 2) ;
- $email_u = $email_array [0] ;
- $l = ereg_replace ('[^a-z0-9]', '', $email_u) ;
- $l = substr ($l, 0, 15) ;
+ $email_u = $email_array [0];
+ $l = preg_replace('/[^a-z0-9]/', '', $email_u);
+ $l = substr ($l, 0, 15);
// Is the user part of the email address okay?
if (account_namevalid($l)
&& db_numrows(db_query_params('SELECT user_id FROM users WHERE user_name = $1',
- array ($l))) == 0) {
+ array($l))) == 0) {
$unix_name = $l ;
} else {
// No? What if we add a number at the end?
$c = substr ($l, 0, 15-strlen ("$i")) . "$i" ;
if (account_namevalid($c)
&& db_numrows(db_query_params('SELECT user_id FROM users WHERE user_name = $1',
- array ($c))) == 0) {
- $unix_name = $c ;
+ array($c))) == 0) {
+ $unix_name = $c;
break;
}
- $i++ ;
+ $i++;
}
}
// If we're really unlucky, then let's go brute-force
while (!$unix_name) {
- $c = substr (md5($email . util_randbytes()), 0, 15) ;
+ $c = substr (md5($email . util_randbytes()), 0, 15);
if (account_namevalid($c)
&& db_numrows(db_query_params('SELECT user_id FROM users WHERE user_name = $1',
- array ($c))) == 0) {
- $unix_name = $c ;
+ array($c))) == 0) {
+ $unix_name = $c;
}
}
}
- $unix_name=strtolower($unix_name);
+ $unix_name = strtolower($unix_name);
if (!account_namevalid($unix_name)) {
$this->setError(_('Invalid Unix Name.'));
return false;
// if we got this far, it must be good
$confirm_hash = substr(md5($password1 . util_randbytes() . microtime()),0,16);
db_begin();
- $result = db_query_params('INSERT INTO users (user_name,user_pw,unix_pw,realname,firstname,lastname,email,add_date,status,confirm_hash,mail_siteupdates,mail_va,language,timezone,jabber_address,jabber_only,unix_box,address,address2,phone,fax,title,ccode,theme_id,tooltips)
- VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25)',
- $result = db_query_params ('INSERT INTO users (user_name,user_pw,unix_pw,realname,firstname,lastname,email,add_date,status,confirm_hash,mail_siteupdates,mail_va,language,timezone,unix_box,address,address2,phone,fax,title,ccode,theme_id) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22)',
- array ($unix_name,
- md5($password1),
- account_genunixpw($password1),
- htmlspecialchars($firstname.' '.$lastname),
- htmlspecialchars($firstname),
- htmlspecialchars($lastname),
- $email,
- time(),
- 'P',
- $confirm_hash,
- (($mail_site)?"1":"0"),
- (($mail_va)?"1":"0"),
- $language_id,
- $timezone,
- $unix_box,
- htmlspecialchars($address),
- htmlspecialchars($address2),
- htmlspecialchars($phone),
- htmlspecialchars($fax),
- htmlspecialchars($title),
- $ccode,
- $theme_id)) ;
++ $result = db_query_params('INSERT INTO users (user_name,user_pw,unix_pw,realname,firstname,lastname,email,add_date,status,confirm_hash,mail_siteupdates,mail_va,language,timezone,unix_box,address,address2,phone,fax,title,ccode,theme_id,tooltips)
++ VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23)',
+ array($unix_name,
+ md5($password1),
+ account_genunixpw($password1),
+ htmlspecialchars($firstname.' '.$lastname),
+ htmlspecialchars($firstname),
+ htmlspecialchars($lastname),
+ $email,
+ time(),
+ 'P',
+ $confirm_hash,
+ (($mail_site)?"1":"0"),
+ (($mail_va)?"1":"0"),
+ $language_id,
+ $timezone,
- $jabber_address,
- $jabber_only,
+ $unix_box,
+ htmlspecialchars($address),
+ htmlspecialchars($address2),
+ htmlspecialchars($phone),
+ htmlspecialchars($fax),
+ htmlspecialchars($title),
+ $ccode,
+ $theme_id,
+ $tooltips));
if (!$result) {
$this->setError(_('Insert Failed: ') . db_error());
db_rollback();
return false;
} else {
- $id = db_insertid($result,'users','user_id');
+ $id = db_insertid($result, 'users', 'user_id');
if (!$id) {
$this->setError('Could Not Get USERID: ' .db_error());
db_rollback();
return false;
}
- $hook_params = array ();
+ $hook_params = array();
$hook_params['user'] = $this;
$hook_params['user_id'] = $this->getID();
$hook_params['user_name'] = $unix_name;
$hook_params['user_password'] = $password1;
- plugin_hook ("user_create", $hook_params);
-
+ plugin_hook("user_create", $hook_params);
+
if ($send_mail) {
setup_gettext_from_lang_id($language_id);
$this->sendRegistrationEmail();
}
/**
- * sendRegistrationEmail() - Send email for registration verification
+ * sendRegistrationEmail() - Send email for registration verification
*
- * @return true or false
+ * @return bool success or not
*/
function sendRegistrationEmail() {
$message=stripcslashes(sprintf(_('Thank you for registering on the %3$s web site. You have
account with username %1$s created for you. In order
-to complete your registration, visit the following url:
+to complete your registration, visit the following url:
<%2$s>
-- the %3$s staff
'),
$this->getUnixName(),
- util_make_url ('/account/verify.php?confirm_hash=_'.$this->getConfirmHash()),
- forge_get_config ('forge_name')));
+ util_make_url('/account/verify.php?confirm_hash=_'.$this->getConfirmHash()),
+ forge_get_config('forge_name')));
util_send_message(
$this->getEmail(),
- sprintf(_('%1$s Account Registration'), forge_get_config ('forge_name')),
+ sprintf(_('%1$s Account Registration'), forge_get_config('forge_name')),
$message
);
}
/**
- * delete() - remove the User from all his groups.
+ * delete() - remove the User from all his groups.
*
- * Remove the User from all his groups and set his status to D.
+ * Remove the User from all his groups and set his status to D.
*
- * @param boolean Confirmation of deletion.
- * @return true or false
+ * @param boolean Confirmation of deletion.
+ * @return boolean success or not
*/
function delete($sure) {
if (!$sure) {
}
db_begin();
- $res = db_query_params ('DELETE FROM artifact_monitor WHERE user_id=$1',
- array ($this->getID())) ;
+ $res = db_query_params('DELETE FROM artifact_monitor WHERE user_id=$1',
+ array($this->getID()));
if (!$res) {
- $this->setError('ERROR - Could Not Delete From artifact_monitor: '.db_error());
+ $this->setError('ERROR - ' . _('Could Not Delete From artifact_monitor:') . ' '.db_error());
db_rollback();
return false;
}
- $res = db_query_params ('DELETE FROM artifact_type_monitor WHERE user_id=$1',
- array ($this->getID())) ;
+ $res = db_query_params('DELETE FROM artifact_type_monitor WHERE user_id=$1',
+ array($this->getID()));
if (!$res) {
- $this->setError('ERROR - Could Not Delete From artifact_type_monitor: '.db_error());
+ $this->setError('ERROR - ' . _('Could Not Delete From artifact_type_monitor:') . ' ' .db_error());
db_rollback();
return false;
}
- $res = db_query_params ('DELETE FROM forum_monitored_forums WHERE user_id=$1',
- array ($this->getID())) ;
+ $res = db_query_params('DELETE FROM forum_monitored_forums WHERE user_id=$1',
+ array($this->getID()));
if (!$res) {
- $this->setError('ERROR - Could Not Delete From forum_monitored_forums: '.db_error());
+ $this->setError('ERROR - ' . _('Could Not Delete From forum_monitored_forums:') . ' '.db_error());
db_rollback();
return false;
- }
- $res = db_query_params ('DELETE FROM filemodule_monitor WHERE user_id=$1',
- array ($this->getID())) ;
+ }
+ $res = db_query_params('DELETE FROM filemodule_monitor WHERE user_id=$1',
+ array($this->getID()));
if (!$res) {
- $this->setError('ERROR - Could Not Delete From filemodule_monitor: '.db_error());
+ $this->setError('ERROR - ' . _('Could Not Delete From filemodule_monitor:') . ' '.db_error());
db_rollback();
return false;
}
$hook_params = array ();
$hook_params['user'] = $this;
$hook_params['user_id'] = $this->getID();
- plugin_hook ("user_delete", $hook_params);
-
+ plugin_hook("user_delete", $hook_params);
+
$this->setStatus('D');
$this->setUnixStatus('D');
db_commit();
}
/**
- * update() - update *common* properties of GFUser object.
- *
- * Use specific setter to change other properties.
- *
- * @param string The users first name.
- * @param string The users last name.
- * @param int The ID of the users language preference.
- * @param string The useres timezone preference.
- * @param string The users preference for receiving site updates by email.
- * @param string The users preference for receiving community updates by email.
- * @param string The users preference for being participating in "peer ratings".
- * @param ignored (no longer used)
- * @param ignored (no longer used)
- * @param int The users theme_id preference.
- * @param string The users address.
- * @param string The users address2.
- * @param string The users phone.
- * @param string The users fax.
- * @param string The users title.
- * @param string The users ccode.
+ * update() - update *common* properties of GFUser object.
+ *
+ * Use specific setter to change other properties.
+ *
+ * @param string The users first name.
+ * @param string The users last name.
+ * @param int The ID of the users language preference.
+ * @param string The useres timezone preference.
+ * @param string The users preference for receiving site updates by email.
+ * @param string The users preference for receiving community updates by email.
+ * @param string The users preference for being participating in "peer ratings".
- * @param string The users Jabber account address.
- * @param int The users Jabber preference.
++ * @param ignored (no longer used)
++ * @param ignored (no longer used)
+ * @param int The users theme_id preference.
+ * @param string The users address.
+ * @param string The users address2.
+ * @param string The users phone.
+ * @param string The users fax.
+ * @param string The users title.
+ * @param string The users ccode.
+ * @param int The users preference for tooltips.
+ * @param string The users email.
*/
- function update($firstname,$lastname,$language_id,$timezone,$mail_site,$mail_va,$use_ratings,
- $dummy1,$dummy2,$theme_id,$address,$address2,$phone,$fax,$title,$ccode) {
+ function update($firstname, $lastname, $language_id, $timezone, $mail_site, $mail_va, $use_ratings,
- $jabber_address, $jabber_only, $theme_id, $address, $address2, $phone, $fax, $title, $ccode, $tooltips, $email='') {
++ $dummy1, $dummy2, $theme_id, $address, $address2, $phone, $fax, $title, $ccode, $tooltips, $email='') {
$mail_site = $mail_site ? 1 : 0;
$mail_va = $mail_va ? 1 : 0;
$block_ratings = $use_ratings ? 0 : 1;
- if ($jabber_address && !validate_email($jabber_address)) {
- $this->setError(_('Invalid Jabber Address'));
- return false;
- }
- if (!$jabber_only) {
- $jabber_only = 0;
- } else {
- $jabber_only = 1;
- }
-
db_begin();
- $res = db_query_params ('
- UPDATE users
- SET
- realname=$1,
- firstname=$2,
- lastname=$3,
- language=$4,
- timezone=$5,
- mail_siteupdates=$6,
- mail_va=$7,
- block_ratings=$8,
- address=$9,
- address2=$10,
- phone=$11,
- fax=$12,
- title=$13,
- ccode=$14,
- theme_id=$15
- WHERE user_id=$16',
- array (
- htmlspecialchars($firstname . ' ' .$lastname),
- htmlspecialchars($firstname),
- htmlspecialchars($lastname),
- $language_id,
- $timezone,
- $mail_site,
- $mail_va,
- $block_ratings,
- htmlspecialchars($address) ,
- htmlspecialchars($address2) ,
- htmlspecialchars($phone) ,
- htmlspecialchars($fax) ,
- htmlspecialchars($title) ,
- $ccode,
- $theme_id,
- $this->getID())) ;
+ $res = db_query_params('
+ UPDATE users
+ SET
+ realname=$1,
+ firstname=$2,
+ lastname=$3,
+ language=$4,
+ timezone=$5,
+ mail_siteupdates=$6,
+ mail_va=$7,
+ block_ratings=$8,
- jabber_address=$9,
- jabber_only=$10,
- address=$11,
- address2=$12,
- phone=$13,
- fax=$14,
- title=$15,
- ccode=$16,
- theme_id=$17,
- tooltips=$18
- WHERE user_id=$19',
++ address=$9,
++ address2=$10,
++ phone=$11,
++ fax=$12,
++ title=$13,
++ ccode=$14,
++ theme_id=$15,
++ tooltips=$16
++ WHERE user_id=$17',
+ array (
+ htmlspecialchars($firstname . ' ' .$lastname),
+ htmlspecialchars($firstname),
+ htmlspecialchars($lastname),
+ $language_id,
+ $timezone,
+ $mail_site,
+ $mail_va,
+ $block_ratings,
- $jabber_address,
- $jabber_only,
+ htmlspecialchars($address),
+ htmlspecialchars($address2),
+ htmlspecialchars($phone),
+ htmlspecialchars($fax),
+ htmlspecialchars($title),
+ $ccode,
+ $theme_id,
+ $tooltips,
+ $this->getID()));
if (!$res) {
$this->setError(_('ERROR - Could Not Update User Object:'). ' ' .db_error());
db_rollback();
return false;
- } else {
- // If there's a transaction from using to not
- // using ratings, remove all rating made by the
- // user (ratings by others should not be removed,
- // as it opens possibility to abuse rate system)
- if (!$use_ratings && $this->usesRatings()) {
- db_query_params ('DELETE FROM user_ratings WHERE rated_by=$1',
- array($user_id));
- }
- if (!$this->fetchData($this->getID())) {
- db_rollback();
- return false;
- }
-
- $hook_params = array ();
- $hook_params['user'] = $this;
- $hook_params['user_id'] = $this->getID();
- plugin_hook ("user_update", $hook_params);
-
- db_commit();
- return true;
}
+
+ if ($email && $email != $this->getEmail()
+ && !$this->setEmail($email)) {
+ return false;
+ }
+
+ // If there's a transaction from using to not
+ // using ratings, remove all rating made by the
+ // user (ratings by others should not be removed,
+ // as it opens possibility to abuse rate system)
+ if (!$use_ratings && $this->usesRatings()) {
+ db_query_params('DELETE FROM user_ratings WHERE rated_by=$1',
+ array($user_id));
+ }
+ if (!$this->fetchData($this->getID())) {
+ db_rollback();
+ return false;
+ }
+
+ $hook_params = array ();
+ $hook_params['user'] = $this;
+ $hook_params['user_id'] = $this->getID();
+ plugin_hook ("user_update", $hook_params);
+
+ db_commit();
+ return true;
}
/**
- * fetchData - May need to refresh database fields.
+ * fetchData - May need to refresh database fields.
*
- * If an update occurred and you need to access the updated info.
+ * If an update occurred and you need to access the updated info.
*
- * @return boolean success;
+ * @param int the User ID data to be fecthed
+ * @return boolean success;
*/
function fetchData($user_id) {
$res = db_query_params ('SELECT * FROM users WHERE user_id=$1',
$this->data_array = db_fetch_array($res);
return true;
}
-
+
/**
- * getID - Simply return the user_id for this object.
+ * getID - Simply return the user_id for this object.
*
- * @return int This user's user_id number.
+ * @return int This user's user_id number.
*/
function getID() {
return $this->data_array['user_id'];
}
/**
- * getStatus - get the status of this user.
+ * getStatus - get the status of this user.
*
- * Statuses include (A)ctive, (P)ending, (S)uspended ,(D)eleted.
+ * Statuses include (A)ctive, (P)ending, (S)uspended ,(D)eleted.
*
- * @return char This user's status flag.
+ * @return char This user's status flag.
*/
function getStatus() {
return $this->data_array['status'];
}
/**
- * setStatus - set this user's status.
+ * setStatus - set this user's status.
*
- * @param string Status - P, A, S, or D.
- * @return boolean success.
+ * @param string Status - P, A, S, or D.
+ * @return boolean success.
*/
function setStatus($status) {
$hook_params['user_id'] = $this->getID();
$hook_params['status'] = $status;
plugin_hook ("user_setstatus", $hook_params);
-
+
db_commit();
-
+
return true;
}
}
/**
- * isActive - whether this user is confirmed and active.
+ * isActive - whether this user is confirmed and active.
*
- * Database field status of 'A' returns true.
- * @return boolean is_active.
+ * Database field status of 'A' returns true.
+ * @return boolean is_active.
*/
function isActive() {
if ($this->getStatus()=='A') {
}
/**
- * getUnixStatus - Status of activation of unix account.
+ * getUnixStatus - Status of activation of unix account.
*
- * @return char (N)one, (A)ctive, (S)uspended or (D)eleted
+ * @return char (N)one, (A)ctive, (S)uspended or (D)eleted
*/
function getUnixStatus() {
return $this->data_array['unix_status'];
}
/**
- * setUnixStatus - Sets status of activation of unix account.
+ * setUnixStatus - Sets status of activation of unix account.
*
- * @param string The unix status.
+ * @param string The unix status.
* N no_unix_account
* A active
* S suspended
* D deleted
*
- * @return boolean success.
+ * @return boolean success.
*/
function setUnixStatus($status) {
global $SYS;
}
}
}
-
+
$this->data_array['unix_status']=$status;
db_commit();
return true;
}
/**
- * getUnixName - the user's unix_name.
+ * getUnixName - the user's unix_name.
*
- * @return string This user's unix/login name.
+ * @return string This user's unix/login name.
*/
function getUnixName() {
return strtolower($this->data_array['user_name']);
}
/**
- * getUnixPasswd - get the user's password.
+ * getUnixPasswd - get the user's password.
*
- * @return string This user's unix crypted passwd.
+ * @return string This user's unix crypted passwd.
*/
function getUnixPasswd() {
return $this->data_array['unix_pw'];
}
/**
- * getUnixBox - the hostname of the unix box this user has an account on.
+ * getUnixBox - the hostname of the unix box this user has an account on.
*
- * @return string This user's shell login machine.
+ * @return string This user's shell login machine.
*/
function getUnixBox() {
return $this->data_array['unix_box'];
}
/**
- * getMD5Passwd - the password.
+ * getMD5Passwd - the password.
*
- * @return string This user's MD5-crypted passwd.
+ * @return string This user's MD5-crypted passwd.
*/
function getMD5Passwd() {
return $this->data_array['user_pw'];
}
-
+
//Added to be compatible with codendi getUserPw function
function getUserPw() {
- return $this->data_array['user_pw'];
+ return $this->data_array['user_pw'];
}
/**
- * getConfirmHash - the confirm hash in the db.
+ * getConfirmHash - the confirm hash in the db.
*
- * @return string This user's confirmation hash.
+ * @return string This user's confirmation hash.
*/
function getConfirmHash() {
return $this->data_array['confirm_hash'];
}
/**
- * getEmail - the user's email address.
+ * getEmail - the user's email address.
*
- * @return string This user's email address.
+ * @return string This user's email address.
*/
function getEmail() {
return str_replace("\n", "", $this->data_array['email']);
}
-
+
/**
* getSha1Email - a SHA1 encoded hash of the email URI (including mailto: prefix)
- *
+ *
* @return string The SHA1 encoded value for the email
*/
function getSha1Email() {
}
/**
- * getNewEmail - while changing an email address, it is stored here until confirmation.
+ * getNewEmail - while changing an email address, it is stored here until confirmation.
*
- * getNewEmail is a private operation for email change.
+ * getNewEmail is a private operation for email change.
*
- * @return string This user's new (not yet confirmed) email address.
- * @private
+ * @return string This user's new (not yet confirmed) email address.
+ * @private
*/
function getNewEmail() {
return $this->data_array['email_new'];
}
/**
- * setEmail - set a new email address, which must be confirmed.
+ * setEmail - set a new email address, which must be confirmed.
*
- * @param string The email address.
- * @return boolean success.
+ * @param string The email address.
+ * @return boolean success.
*/
function setEmail($email) {
db_begin();
$res = db_query_params ('UPDATE users SET email=$1 WHERE user_id=$2',
array ($email,
- $this->getID())) ;
+ $this->getID()));
if (!$res) {
$this->setError('ERROR - Could Not Update User Email: '.db_error());
$hook_params['user'] = $this;
$hook_params['user_id'] = $this->getID();
$hook_params['user_email'] = $email;
- plugin_hook ("user_setemail", $hook_params);
-
+ plugin_hook("user_setemail", $hook_params);
+
if (!$this->fetchData($this->getId())) {
db_rollback();
return false;
}
/**
- * setNewEmailAndHash - setNewEmailAndHash is a private operation for email change.
+ * setNewEmailAndHash - setNewEmailAndHash is a private operation for email change.
*
- * @param string The email address.
- * @param string The email hash.
- * @return boolean success.
+ * @param string The email address.
+ * @param string The email hash.
+ * @return boolean success.
*/
function setNewEmailAndHash($email, $hash='') {
}
}
$res = db_query_params ('UPDATE users SET confirm_hash=$1, email_new=$2 WHERE user_id=$3',
- array ($hash,
+ array($hash,
$email,
- $this->getID())) ;
+ $this->getID()));
if (!$res) {
$this->setError('ERROR - Could Not Update User Email And Hash: '.db_error());
return false;
} else {
- $this->data_array['email_new'] = $email;
+ $this->data_array['email_new'] = $email;
$this->data_array['confirm_hash'] = $hash;
return true;
}
}
/**
- * getRealName - get the user's real name.
+ * getRealName - get the user's real name.
*
- * @return string This user's real name.
+ * @return string This user's real name.
*/
function getRealName() {
$last_name = $this->getLastName();
}
/**
- * getFirstName - get the user's first name.
+ * getFirstName - get the user's first name.
*
- * @return string This user's first name.
+ * @return string This user's first name.
*/
function getFirstName() {
return $this->data_array['firstname'];
}
/**
- * getLastName - get the user's last name.
+ * getLastName - get the user's last name.
*
- * @return string This user's last name.
+ * @return string This user's last name.
*/
function getLastName() {
return $this->data_array['lastname'];
}
/**
- * getAddDate - this user's unix time when account was opened.
+ * getAddDate - this user's unix time when account was opened.
*
- * @return int This user's unix time when account was opened.
+ * @return int This user's unix time when account was opened.
*/
function getAddDate() {
return $this->data_array['add_date'];
}
/**
- * getTimeZone - this user's timezone setting.
+ * getTimeZone - this user's timezone setting.
*
- * @return string This user's timezone setting.
+ * @return string This user's timezone setting.
*/
function getTimeZone() {
return $this->data_array['timezone'];
}
/**
- * getCountryCode - this user's ccode setting.
+ * getCountryCode - this user's ccode setting.
*
- * @return string This user's ccode setting.
+ * @return string This user's ccode setting.
*/
function getCountryCode() {
return $this->data_array['ccode'];
}
/**
- * getShell - this user's preferred shell.
+ * getShell - this user's preferred shell.
*
- * @return string This user's preferred shell.
+ * @return string This user's preferred shell.
*/
function getShell() {
return $this->data_array['shell'];
}
/**
- * setShell - sets user's preferred shell.
+ * setShell - sets user's preferred shell.
*
- * @param string The users preferred shell.
- * @return boolean success.
+ * @param string The users preferred shell.
+ * @return boolean success.
*/
function setShell($shell) {
global $SYS;
}
/**
- * getUnixUID() - Get the unix UID of the user
+ * getUnixUID() - Get the unix UID of the user
*
- * @return int This user's UID.
+ * @return int This user's UID.
*/
function getUnixUID() {
return $this->data_array['unix_uid'];
}
/**
- * getUnixGID() - Get the unix GID of the user
+ * getUnixGID() - Get the unix GID of the user
*
- * @return int This user's GID.
+ * @return int This user's GID.
*/
function getUnixGID() {
return $this->data_array['unix_gid'];
}
/**
- * getLanguage - this user's language_id from supported_languages table.
+ * getLanguage - this user's language_id from supported_languages table.
*
- * @return int This user's language_id.
+ * @return int This user's language_id.
*/
function getLanguage() {
return $this->data_array['language'];
}
- /**
- * getJabberAddress - this user's optional jabber address.
- *
- * @return string This user's jabber address.
- */
- function getJabberAddress() {
- return $this->data_array['jabber_address'];
- }
-
- /**
- * getJabberOnly - whether this person wants updates sent ONLY to jabber.
- *
- * @return boolean This user's jabber preference.
- */
- function getJabberOnly() {
- return $this->data_array['jabber_only'];
- }
-
/**
- * getAddress - get this user's address.
+ * getAddress - get this user's address.
*
- * @return text This user's address.
+ * @return text This user's address.
*/
function getAddress() {
return $this->data_array['address'];
}
/**
- * getAddress2 - get this user's address2.
+ * getAddress2 - get this user's address2.
*
- * @return text This user's address2.
+ * @return text This user's address2.
*/
function getAddress2() {
return $this->data_array['address2'];
}
/**
- * getPhone - get this person's phone number.
+ * getPhone - get this person's phone number.
*
- * @return text This user's phone number.
+ * @return text This user's phone number.
*/
function getPhone() {
return $this->data_array['phone'];
}
/**
- * getFax - get this person's fax number.
+ * getFax - get this person's fax number.
*
- * @return text This user's fax.
+ * @return text This user's fax.
*/
function getFax() {
return $this->data_array['fax'];
}
/**
- * getTitle - get this person's title.
+ * getTitle - get this person's title.
*
- * @return text This user's title.
+ * @return text This user's title.
*/
function getTitle() {
return $this->data_array['title'];
}
/**
- * getGroups - get an array of groups this user is a member of.
+ * getGroups - get an array of groups this user is a member of.
*
- * @return array Array of groups.
+ * @return array Array of groups.
*/
function &getGroups($onlylocal = true) {
- $ids = array () ;
+ $ids = array();
foreach ($this->getRoles() as $r) {
if ($onlylocal) {
if ($r instanceof RoleExplicit
&& $r->getHomeProject() != NULL) {
- $ids[] = $r->getHomeProject()->getID() ;
+ $ids[] = $r->getHomeProject()->getID();
}
} else {
foreach ($r->getLinkedProjects() as $p) {
- $ids[] = $p->getID() ;
+ $ids[] = $p->getID();
}
}
}
}
/**
- * getAuthorizedKeys - the SSH authorized keys set by the user.
+ * getAuthorizedKeys - the SSH authorized keys set by the user.
*
- * @return string This user's SSH authorized (public) keys.
+ * @return string This user's SSH authorized (public) keys.
*/
function getAuthorizedKeys() {
return preg_replace("/###/", "\n", $this->data_array['authorized_keys']);
/**
* setAuthorizedKeys - set the SSH authorized keys for the user.
*
- * @param string The users public keys.
- * @return boolean success.
+ * @param string The users public keys.
+ * @return boolean success.
*/
function setAuthorizedKeys($keys) {
$keys = trim($keys);
$keys = preg_replace("/\n+/", "\n", $keys); // Remove empty lines
$keys = preg_replace("/\n/", "###", $keys); // Convert EOL to marker
- $res = db_query_params ('UPDATE users SET authorized_keys=$1 WHERE user_id=$2',
- array ($keys,
- $this->getID())) ;
+ $res = db_query_params('UPDATE users SET authorized_keys=$1 WHERE user_id=$2',
+ array($keys,
+ $this->getID()));
if (!$res) {
$this->setError(_('ERROR - Could Not Update User SSH Keys'));
return false;
}
/**
- * setLoggedIn($val) - Really only used by session code.
+ * setLoggedIn($val) - Really only used by session code.
*
- * @param boolean The session value.
+ * @param boolean The session value.
*/
- function setLoggedIn ($val=true) {
+ function setLoggedIn($val=true) {
$this->is_logged_in = $val;
if ($val) {
- $this->is_super_user = forge_check_global_perm_for_user ($this, 'forge_admin') ;
+ $this->is_super_user = forge_check_global_perm_for_user($this, 'forge_admin') ;
}
}
/**
- * isLoggedIn - only used by session code.
+ * isLoggedIn - only used by session code.
*
- * @return boolean is_logged_in.
+ * @return boolean is_logged_in.
*/
function isLoggedIn() {
return $this->is_logged_in;
}
/**
- * deletePreference - delete a preference for this user.
+ * deletePreference - delete a preference for this user.
*
- * @param string The unique field name for this preference.
- * @return boolean success.
+ * @param string The unique field name for this preference.
+ * @return boolean success.
*/
function deletePreference($preference_name) {
$preference_name=strtolower(trim($preference_name));
unset($this->user_pref["$preference_name"]);
- $res = db_query_params ('DELETE FROM user_preferences WHERE user_id=$1 AND preference_name=$2',
+ $res = db_query_params('DELETE FROM user_preferences WHERE user_id=$1 AND preference_name=$2',
array ($this->getID(),
- $preference_name)) ;
+ $preference_name));
return ((!$res || db_affected_rows($res) < 1) ? false : true);
}
/**
- * setPreference - set a new preference for this user.
+ * setPreference - set a new preference for this user.
*
- * @param string The unique field name for this preference.
- * @param string The value you are setting this preference to.
- * @return boolean success.
+ * @param string The unique field name for this preference.
+ * @param string The value you are setting this preference to.
+ * @return boolean success.
*/
function setPreference($preference_name,$value) {
$preference_name=strtolower(trim($preference_name));
}
/**
- * getPreference - get a specific preference.
+ * getPreference - get a specific preference.
*
- * @param string The unique field name for this preference.
- * @return the preference string or false on failure.
+ * @param string The unique field name for this preference.
+ * @return string|bool the preference string or false on failure.
*/
function getPreference($preference_name) {
$preference_name=strtolower(trim($preference_name));
}
/**
- * setPasswd - Changes user's password.
+ * setPasswd - Changes user's password.
*
- * @param string The plaintext password.
- * @return boolean success.
+ * @param string The plaintext password.
+ * @return boolean success.
*/
function setPasswd($passwd) {
global $SYS;
}
/**
- * usesRatings - whether user participates in rating system.
+ * setMD5Passwd - Changes user's MD5 password.
+ *
+ * @param string The MD5-hashed password.
+ * @return boolean success.
+ */
+ function setMD5Passwd($md5) {
+ global $SYS;
+
+ db_begin();
+
+ if ($md5) {
+ $res = db_query_params('UPDATE users SET user_pw=$1 WHERE user_id=$2',
+ array($md5_pw,
+ $this->getID()));
+
+ if (!$res || db_affected_rows($res) < 1) {
+ $this->setError(_('ERROR - Could Not Change User Password:') . ' ' .db_error());
+ db_rollback();
+ return false;
+ }
+ }
+ db_commit();
+ return true;
+ }
+
+ /**
+ * setUnixPasswd - Changes user's Unix-hashed password.
+ *
+ * @param string The Unix-hashed password.
+ * @return boolean success.
+ */
+ function setUnixPasswd($unix) {
+ global $SYS;
+
+ db_begin();
+
+ if ($unix) {
+ $res = db_query_params('UPDATE users SET unix_pw=$1 WHERE user_id=$1',
+ array ($unix_pw,
+ $this->getID()));
+
+ if (!$res || db_affected_rows($res) < 1) {
+ $this->setError(_('ERROR - Could Not Change User Password:') . ' ' .db_error());
+ db_rollback();
+ return false;
+ }
+
+ // Now change system password, but only if corresponding
+ // entry exists (i.e. if user have shell access)
+ if ($SYS->sysCheckUser($this->getID())) {
+ if (!$SYS->sysUserSetAttribute($this->getID(),"userPassword",'{crypt}'.$unix)) {
+ $this->setError($SYS->getErrorMessage());
+ db_rollback();
+ return false;
+ }
+ }
+ }
+ db_commit();
+ return true;
+ }
+
+ /**
+ * usesRatings - whether user participates in rating system.
*
- * @return boolean success.
+ * @return boolean success.
*/
function usesRatings() {
return !$this->data_array['block_ratings'];
}
/**
- * getPlugins - get a list of all available user plugins
+ * usesTooltips - whether user enables or not tooltips.
*
- * @return array array containing plugin_id => plugin_name
+ * @return boolean success.
+ */
+ function usesTooltips() {
+ return $this->data_array['tooltips'];
+ }
+
+ /**
+ * getPlugins - get a list of all available user plugins
+ *
+ * @return array array containing plugin_id => plugin_name
*/
function getPlugins() {
if (!isset($this->plugins_data)) {
$this->plugins_data = array () ;
$res = db_query_params ('SELECT user_plugin.plugin_id, plugins.plugin_name
- FROM user_plugin, plugins
- WHERE user_plugin.user_id=$1
- AND user_plugin.plugin_id=plugins.plugin_id',
+ FROM user_plugin, plugins
+ WHERE user_plugin.user_id=$1
+ AND user_plugin.plugin_id=plugins.plugin_id',
array ($this->getID())) ;
$rows = db_numrows($res);
}
/**
- * usesPlugin - returns true if the user uses a particular plugin
+ * usesPlugin - returns true if the user uses a particular plugin
*
- * @param string name of the plugin
- * @return boolean whether plugin is being used or not
+ * @param string name of the plugin
+ * @return boolean whether plugin is being used or not
*/
function usesPlugin($pluginname) {
$plugins_data = $this->getPlugins() ;
}
/**
- * setPluginUse - enables/disables plugins for the user
+ * setPluginUse - enables/disables plugins for the user
*
- * @param string name of the plugin
- * @param boolean the new state
- * @return string database result
+ * @param string name of the plugin
+ * @param boolean the new state
+ * @return string database result
*/
function setPluginUse($pluginname, $val=true) {
if ($val == $this->usesPlugin($pluginname)) {
// State is already good, returning
- return true ;
+ return true;
}
- $res = db_query_params ('SELECT plugin_id FROM plugins WHERE plugin_name=$1',
- array ($pluginname)) ;
+ $res = db_query_params('SELECT plugin_id FROM plugins WHERE plugin_name=$1',
+ array($pluginname));
$rows = db_numrows($res);
if ($rows == 0) {
// Error: no plugin by that name
}
$plugin_id = db_result($res,0,'plugin_id');
// Invalidate cache
- unset ($this->plugins_data) ;
+ unset ($this->plugins_data);
if ($val) {
- return db_query_params ('INSERT INTO user_plugin (user_id,plugin_id) VALUES ($1,$2)',
- array ($this->getID(),
- $plugin_id)) ;
+ return db_query_params('INSERT INTO user_plugin (user_id,plugin_id) VALUES ($1,$2)',
+ array($this->getID(),
+ $plugin_id));
} else {
- return db_query_params ('DELETE FROM user_plugin WHERE user_id=$1 AND plugin_id=$2',
- array ($this->getID(),
- $plugin_id)) ;
+ return db_query_params('DELETE FROM user_plugin WHERE user_id=$1 AND plugin_id=$2',
+ array($this->getID(),
+ $plugin_id));
}
}
/**
- * getMailingsPrefs - Get activity status for one of the site mailings.
+ * getMailingsPrefs - Get activity status for one of the site mailings.
*
- * @param string The id of mailing ('mail_va' for community mailings, 'mail_siteupdates' for site mailings)
- * @return boolean success.
+ * @param string The id of mailing ('mail_va' for community mailings, 'mail_siteupdates' for site mailings)
+ * @return boolean success.
*/
function getMailingsPrefs($mailing_id) {
- if ($mailing_id=='va') {
+ if ($mailing_id == 'va') {
return $this->data_array['mail_va'];
- } else if ($mailing_id=='site') {
+ } else if ($mailing_id == 'site') {
return $this->data_array['mail_siteupdates'];
} else {
return 0;
}
/**
- * unsubscribeFromMailings - Disable email notifications for user.
+ * unsubscribeFromMailings - Disable email notifications for user.
*
- * @param boolean If false, disable general site mailings, else - all.
- * @return boolean success.
+ * @param boolean If false, disable general site mailings, else - all.
+ * @return boolean success.
*/
- function unsubscribeFromMailings($all=false) {
+ function unsubscribeFromMailings($all = false) {
$res1 = $res2 = $res3 = true;
$res1 = db_query_params ('UPDATE users SET mail_siteupdates=0, mail_va=0 WHERE user_id=$1',
array ($this->getID())) ;
if ($all) {
- $res2 = db_query_params ('DELETE FROM forum_monitored_forums WHERE user_id=$1',
+ $res2 = db_query_params('DELETE FROM forum_monitored_forums WHERE user_id=$1',
array ($this->getID())) ;
- $res3 = db_query_params ('DELETE FROM filemodule_monitor WHERE user_id=$1',
+ $res3 = db_query_params('DELETE FROM filemodule_monitor WHERE user_id=$1',
array ($this->getID())) ;
}
}
/**
- * getThemeID - get the theme_id for this user.
+ * getThemeID - get the theme_id for this user.
*
- * @return int The theme_id.
+ * @return int The theme_id.
*/
function getThemeID() {
return $this->data_array['theme_id'];
}
/**
- * getThemeID - get the theme_id for this user from the theme_prefs table.
+ * setUpTheme - get the theme path
*
- * @return int The theme_id.
+ * @return string The theme path.
*/
function setUpTheme() {
//
}
/**
- * getRole() - Get user Role object.
+ * getRole() - Get user Role object.
*
- * @param object group object
- * @return object Role object
+ * @param object group object
+ * @return object Role object
*/
- function getRole(&$group) {
+ function getRole(&$g) {
+ if (is_int ($g) || is_string($g)) {
+ $group_id = $g;
+ } else {
+ $group_id = $g->getID();
+ }
foreach ($this->getRoles () as $r) {
- if ($r instanceof RoleExplicit
- && $r->getHomeProject() != NULL
- && $r->getHomeProject()->getID() == $group->getID()) {
- return $r ;
+ if ($r instanceof RoleExplicit ) {
+ $homeproj = $r->getHomeProject();
+ if ($homeproj) {
+ if ($homeproj->getID() == $group_id) {
+ return $r;
+ }
+ }
}
}
- return false ;
+ return false;
}
- function getRoles () {
- return RBACEngine::getInstance()->getAvailableRolesForUser($this) ;
+ function getRoles() {
+ return RBACEngine::getInstance()->getAvailableRolesForUser($this);
}
/* Codendi Glue */
- function isMember($g,$type=0){
+ function isMember($g, $type = 0){
if (is_int ($g) || is_string($g)) {
$group = group_get_object ($g) ;
$group_id = $g ;
break;
case 'P2':
//pm admin
- return forge_check_perm_for_user($this,'pm_admin',$group_id) ;
- break;
+ return forge_check_perm_for_user($this, 'pm_admin', $group_id);
+ break;
case 'F2':
//forum admin
- return forge_check_perm_for_user($this,'forum_admin',$group_id) ;
- break;
+ return forge_check_perm_for_user($this, 'forum_admin', $group_id);
+ break;
case 'A':
//admin for this group
- return forge_check_perm_for_user($this,'project_admin',$group_id) ;
+ return forge_check_perm_for_user($this, 'project_admin', $group_id);
break;
case 'D1':
//document editor
- return forge_check_perm_for_user($this,'docman',$group_id,'admin') ;
+ return forge_check_perm_for_user($this, 'docman', $group_id, 'admin');
break;
}
}
/**
- * user_ismember() - DEPRECATED; DO NOT USE!
- *
+ * user_ismember() - DEPRECATED; DO NOT USE! (TODO: document what should be used instead)
+ * Replace user_ismember(1[, 'A']) with forge_check_global_perm('forge_admin')
+ * Replace user_ismember($group_id, 'A') with forge_check_perm('project_admin', $group_id)
+ * For now, keep user_ismember($group_id) alone
* @param int The Group ID
* @param int The Type
* @deprecated
}
/**
- * user_getname() - DEPRECATED; DO NOT USE!
+ * user_getname() - DEPRECATED; DO NOT USE! (TODO: document what should be used instead)
*
* @param int The User ID
* @deprecated
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-if (isset ($GLOBALS['sys_name'])) {
+if (file_exists($gfcgfile)) {
forge_define_config_item ('forge_name', 'core', $GLOBALS['sys_name']) ;
-} else {
- forge_define_config_item ('forge_name', 'core', 'FusionForge') ;
-}
-if (isset ($GLOBALS['sys_force_login'])) {
forge_define_config_item ('force_login', 'core', $GLOBALS['sys_force_login']) ;
-} else {
- forge_define_config_item ('force_login', 'core', false) ;
-}
-forge_set_config_item_bool ('force_login', 'core') ;
-if (isset ($GLOBALS['sys_user_reg_restricted'])) {
+ forge_set_config_item_bool ('force_login', 'core') ;
forge_define_config_item ('user_registration_restricted', 'core', $GLOBALS['sys_user_reg_restricted']) ;
-} else {
- forge_define_config_item ('user_registration_restricted', 'core', false) ;
-}
-forge_set_config_item_bool ('user_registration_restricted', 'core') ;
-if (isset ($GLOBALS['sys_project_reg_restricted'])) {
+ forge_set_config_item_bool ('user_registration_restricted', 'core') ;
forge_define_config_item ('project_registration_restricted', 'core', $GLOBALS['sys_project_reg_restricted']) ;
-} else {
- forge_define_config_item ('project_registration_restricted', 'core', false) ;
-}
-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 ('allow_project_without_template', 'core', true) ;
-forge_set_config_item_bool ('allow_project_without_template', 'core') ;
-if (isset ($GLOBALS['sys_default_domain'])) {
+ 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 ('allow_project_without_template', 'core', true) ;
+ forge_set_config_item_bool ('allow_project_without_template', 'core') ;
forge_define_config_item ('web_host', 'core', $GLOBALS['sys_default_domain']) ;
-} else {
- forge_define_config_item ('web_host', 'core', '') ;
-}
-forge_define_config_item ('http_port', 'core', 80) ;
-forge_define_config_item ('https_port', 'core', 443) ;
-if (isset ($GLOBALS['sys_apache_user'])) {
+ forge_define_config_item ('http_port', 'core', 80) ;
+ forge_define_config_item ('https_port', 'core', 443) ;
forge_define_config_item ('apache_user', 'core', $GLOBALS['sys_apache_user']) ;
-} else {
- forge_define_config_item ('apache_user', 'core', '') ;
-}
-if (isset ($GLOBALS['sys_apache_group'])) {
forge_define_config_item ('apache_group', 'core', $GLOBALS['sys_apache_group']) ;
-} else {
- forge_define_config_item ('apache_group', 'core', '') ;
-}
-forge_define_config_item ('scm_tarballs_path', 'core', '$core/data_path/scmtarballs') ;
-forge_define_config_item ('scm_snapshots_path', 'core', '$core/data_path/scmsnapshots') ;
-forge_define_config_item ('plugins_path', 'core', '$core/source_path/plugins') ;
-forge_define_config_item ('themes_root', 'core', '$core/source_path/www/themes') ;
-if (isset ($GLOBALS['sys_theme'])) {
+ forge_define_config_item ('scm_tarballs_path', 'core', '$core/data_path/scmtarballs') ;
+ forge_define_config_item ('scm_snapshots_path', 'core', '$core/data_path/scmsnapshots') ;
+ forge_define_config_item ('plugins_path', 'core', '$core/source_path/plugins') ;
+ forge_define_config_item ('themes_root', 'core', '$core/source_path/www/themes') ;
forge_define_config_item ('default_theme', 'core', $GLOBALS['sys_theme']) ;
-} else {
- forge_define_config_item ('default_theme', 'core', 'gforge') ;
-}
-if (isset ($GLOBALS['sys_lang'])) {
forge_define_config_item ('default_language', 'core', $GLOBALS['sys_lang']) ;
-} else {
- forge_define_config_item ('default_language', 'core', 'en') ;
-}
-if (isset ($GLOBALS['sys_default_timezone'])) {
forge_define_config_item ('default_timezone', 'core', $GLOBALS['sys_default_timezone']) ;
-} else {
- forge_define_config_item ('default_timezone', 'core', 'UTC') ;
-}
-if (isset ($GLOBALS['sys_default_country_code'])) {
forge_define_config_item ('default_country_code', 'core', $GLOBALS['sys_default_country_code']) ;
-} else {
- forge_define_config_item ('default_country_code', 'core', 'US') ;
-}
-if (isset ($GLOBALS['sys_use_scm'])) {
forge_define_config_item ('use_scm', 'core', $GLOBALS['sys_use_scm']) ;
-} else {
- forge_define_config_item ('use_scm', 'core', true) ;
-}
-forge_set_config_item_bool ('use_scm', 'core') ;
-if (isset ($GLOBALS['sys_use_dav'])) {
- forge_define_config_item ('use_dav', 'core', $GLOBALS['sys_use_dav']) ;
-} else {
- forge_define_config_item ('use_dav', 'core', true) ;
-}
-forge_set_config_item_bool ('use_dav', 'core') ;
-if (isset ($GLOBALS['sys_use_tracker'])) {
+ forge_set_config_item_bool ('use_scm', 'core') ;
+ forge_define_config_item ('use_dav', 'core', @$GLOBALS['sys_use_dav']) ;
+ forge_set_config_item_bool ('use_dav', 'core') ;
forge_define_config_item ('use_tracker', 'core', $GLOBALS['sys_use_tracker']) ;
-} else {
- forge_define_config_item ('use_tracker', 'core', true) ;
-}
-forge_set_config_item_bool ('use_tracker', 'core') ;
-if (isset ($GLOBALS['sys_use_forum'])) {
+ forge_set_config_item_bool ('use_tracker', 'core') ;
forge_define_config_item ('use_forum', 'core', $GLOBALS['sys_use_forum']) ;
-} else {
- forge_define_config_item ('use_forum', 'core', true) ;
-}
-forge_set_config_item_bool ('use_forum', 'core') ;
-if (isset ($GLOBALS['sys_use_pm'])) {
+ forge_set_config_item_bool ('use_forum', 'core') ;
forge_define_config_item ('use_pm', 'core', $GLOBALS['sys_use_pm']) ;
-} else {
- forge_define_config_item ('use_pm', 'core', true) ;
-}
-forge_set_config_item_bool ('use_pm', 'core') ;
-if (isset ($GLOBALS['sys_use_docman'])) {
+ forge_set_config_item_bool ('use_pm', 'core') ;
forge_define_config_item ('use_docman', 'core', $GLOBALS['sys_use_docman']) ;
-} else {
- forge_define_config_item ('use_docman', 'core', true) ;
-}
-forge_set_config_item_bool ('use_docman', 'core') ;
-if (isset ($GLOBALS['sys_use_diary'])) {
+ forge_set_config_item_bool ('use_docman', 'core') ;
forge_define_config_item ('use_diary', 'core', $GLOBALS['sys_use_diary']) ;
-} else {
- forge_define_config_item ('use_diary', 'core', false) ;
-}
-forge_set_config_item_bool ('use_diary', 'core') ;
-if (isset ($GLOBALS['sys_use_news'])) {
+ forge_set_config_item_bool ('use_diary', 'core') ;
forge_define_config_item ('use_news', 'core', $GLOBALS['sys_use_news']) ;
-} else {
- forge_define_config_item ('use_news', 'core', true) ;
-}
-forge_set_config_item_bool ('use_news', 'core') ;
-if (isset ($GLOBALS['sys_use_mail'])) {
+ forge_set_config_item_bool ('use_news', 'core') ;
forge_define_config_item ('use_mail', 'core', $GLOBALS['sys_use_mail']) ;
-} else {
- forge_define_config_item ('use_mail', 'core', true) ;
-}
-forge_set_config_item_bool ('use_mail', 'core') ;
-if (isset ($GLOBALS['sys_use_survey'])) {
+ forge_set_config_item_bool ('use_mail', 'core') ;
forge_define_config_item ('use_survey', 'core', $GLOBALS['sys_use_survey']) ;
-} else {
- forge_define_config_item ('use_survey', 'core', true) ;
-}
-forge_set_config_item_bool ('use_survey', 'core') ;
-if (isset ($GLOBALS['sys_use_frs'])) {
+ forge_set_config_item_bool ('use_survey', 'core') ;
forge_define_config_item ('use_frs', 'core', $GLOBALS['sys_use_frs']) ;
-} else {
- forge_define_config_item ('use_frs', 'core', true) ;
-}
-forge_set_config_item_bool ('use_frs', 'core') ;
-if (isset ($GLOBALS['sys_use_project_tags'])) {
+ forge_set_config_item_bool ('use_frs', 'core') ;
forge_define_config_item ('use_project_tags', 'core', $GLOBALS['sys_use_project_tags']) ;
-} else {
- forge_define_config_item ('use_project_tags', 'core', true) ;
-}
-forge_set_config_item_bool ('use_project_tags', 'core') ;
-if (isset ($GLOBALS['sys_use_project_full_list'])) {
+ forge_set_config_item_bool ('use_project_tags', 'core') ;
forge_define_config_item ('use_project_full_list', 'core', $GLOBALS['sys_use_project_full_list']) ;
-} else {
- forge_define_config_item ('use_project_full_list', 'core', true) ;
-}
-forge_set_config_item_bool ('use_project_full_list', 'core') ;
-if (isset ($GLOBALS['sys_use_fti'])) {
+ forge_set_config_item_bool ('use_project_full_list', 'core') ;
forge_define_config_item ('use_fti', 'core', $GLOBALS['sys_use_fti']) ;
-} else {
- forge_define_config_item ('use_fti', 'core', true) ;
-}
-forge_set_config_item_bool ('use_fti', 'core') ;
-if (isset ($GLOBALS['sys_use_ftp'])) {
+ forge_set_config_item_bool ('use_fti', 'core') ;
forge_define_config_item ('use_ftp', 'core', $GLOBALS['sys_use_ftp']) ;
-} else {
- forge_define_config_item ('use_ftp', 'core', false) ;
-}
-forge_set_config_item_bool ('use_ftp', 'core') ;
-if (isset ($GLOBALS['sys_use_trove'])) {
+ forge_set_config_item_bool ('use_ftp', 'core') ;
forge_define_config_item ('use_trove', 'core', $GLOBALS['sys_use_trove']) ;
-} else {
- forge_define_config_item ('use_trove', 'core', true) ;
-}
-forge_set_config_item_bool ('use_trove', 'core') ;
-if (isset ($GLOBALS['sys_use_snippet'])) {
+ forge_set_config_item_bool ('use_trove', 'core') ;
forge_define_config_item ('use_snippet', 'core', $GLOBALS['sys_use_snippet']) ;
-} else {
- forge_define_config_item ('use_snippet', 'core', true) ;
-}
-forge_set_config_item_bool ('use_snippet', 'core') ;
-if (isset ($GLOBALS['sys_use_ssl'])) {
+ forge_set_config_item_bool ('use_snippet', 'core') ;
forge_define_config_item ('use_ssl', 'core', $GLOBALS['sys_use_ssl']) ;
-} else {
- forge_define_config_item ('use_ssl', 'core', true) ;
-}
-forge_set_config_item_bool ('use_ssl', 'core') ;
-if (isset ($GLOBALS['sys_use_people'])) {
+ forge_set_config_item_bool ('use_ssl', 'core') ;
forge_define_config_item ('use_people', 'core', $GLOBALS['sys_use_people']) ;
-} else {
- forge_define_config_item ('use_people', 'core', false) ;
-}
-forge_set_config_item_bool ('use_people', 'core') ;
-if (isset ($GLOBALS['sys_use_shell'])) {
+ forge_set_config_item_bool ('use_people', 'core') ;
forge_define_config_item ('use_shell', 'core', $GLOBALS['sys_use_shell']) ;
-} else {
- forge_define_config_item ('use_shell', 'core', true) ;
-}
-forge_set_config_item_bool ('use_shell', 'core') ;
-if (isset ($GLOBALS['sys_use_ratings'])) {
+ forge_set_config_item_bool ('use_shell', 'core') ;
forge_define_config_item ('use_ratings', 'core', $GLOBALS['sys_use_ratings']) ;
-} else {
- forge_define_config_item ('use_ratings', 'core', true) ;
-}
-forge_set_config_item_bool ('use_ratings', 'core') ;
-if (isset ($GLOBALS['sys_use_ftpuploads'])) {
+ forge_set_config_item_bool ('use_ratings', 'core') ;
forge_define_config_item ('use_ftp_uploads', 'core', $GLOBALS['sys_use_ftpuploads']) ;
-} else {
- forge_define_config_item ('use_ftp_uploads', 'core', true) ;
-}
-forge_set_config_item_bool ('use_ftp_uploads', 'core') ;
-if (isset ($GLOBALS['sys_ftp_upload_dir'])) {
+ forge_set_config_item_bool ('use_ftp_uploads', 'core') ;
forge_define_config_item ('ftp_upload_dir', 'core', $GLOBALS['sys_ftp_upload_dir']) ;
-} else {
- forge_define_config_item ('ftp_upload_dir', 'core', '') ;
-}
-if (isset ($GLOBALS['sys_upload_dir'])) {
forge_define_config_item ('upload_dir', 'core', $GLOBALS['sys_upload_dir']) ;
-} else {
- forge_define_config_item ('upload_dir', 'core', '') ;
-}
-forge_define_config_item ('use_manual_uploads', 'core', isset ($GLOBALS['sys_use_manual_uploads']) ? $GLOBALS['sys_use_manual_uploads'] : false) ;
-forge_set_config_item_bool ('use_manual_uploads', 'core') ;
-if (isset ($GLOBALS['sys_use_gateways'])) {
+ forge_define_config_item ('use_manual_uploads', 'core', isset ($GLOBALS['sys_use_manual_uploads']) ? $GLOBALS['sys_use_manual_uploads'] : false) ;
+ forge_set_config_item_bool ('use_manual_uploads', 'core') ;
forge_define_config_item ('use_gateways', 'core', $GLOBALS['sys_use_gateways']) ;
-} else {
- forge_define_config_item ('use_gateways', 'core', true) ;
-}
-forge_set_config_item_bool ('use_gateways', 'core') ;
-if (isset ($GLOBALS['sys_use_project_vhost'])) {
+ forge_set_config_item_bool ('use_gateways', 'core') ;
forge_define_config_item ('use_project_vhost', 'core', $GLOBALS['sys_use_project_vhost']) ;
-} else {
- forge_define_config_item ('use_project_vhost', 'core', true) ;
-}
-forge_set_config_item_bool ('use_project_vhost', 'core') ;
-if (isset ($GLOBALS['sys_use_project_database'])) {
+ forge_set_config_item_bool ('use_project_vhost', 'core') ;
forge_define_config_item ('use_project_database', 'core', $GLOBALS['sys_use_project_database']) ;
-} else {
- forge_define_config_item ('use_project_database', 'core', false) ;
-}
-forge_set_config_item_bool ('use_project_database', 'core') ;
-if (isset ($GLOBALS['sys_use_project_multimedia'])) {
+ forge_set_config_item_bool ('use_project_database', 'core') ;
forge_define_config_item ('use_project_multimedia', 'core', $GLOBALS['sys_use_project_multimedia']) ;
-} else {
- forge_define_config_item ('use_project_multimedia', 'core', false) ;
-}
-forge_set_config_item_bool ('use_project_multimedia', 'core') ;
-if (isset ($GLOBALS['sys_download_host'])) {
- forge_define_config_item ('download_host', 'core', $GLOBALS['sys_download_host']) ;
-} else {
- forge_define_config_item ('download_host', 'core', '') ;
-}
-if (isset ($GLOBALS['sys_shell_host'])) {
+ forge_set_config_item_bool ('use_project_multimedia', 'core') ;
forge_define_config_item ('shell_host', 'core', $GLOBALS['sys_shell_host']) ;
-} else {
- forge_define_config_item ('shell_host', 'core', '') ;
-}
-if (isset ($GLOBALS['sys_users_host'])) {
forge_define_config_item ('users_host', 'core', $GLOBALS['sys_users_host']) ;
-} else {
- forge_define_config_item ('users_host', 'core', '') ;
-}
-if (isset ($GLOBALS['sys_lists_host'])) {
forge_define_config_item ('lists_host', 'core', $GLOBALS['sys_lists_host']) ;
-} else {
- forge_define_config_item ('lists_host', 'core', '') ;
-}
-if (isset ($GLOBALS['sys_scm_host'])) {
forge_define_config_item ('scm_host', 'core', $GLOBALS['sys_scm_host']) ;
-} else {
- forge_define_config_item ('scm_host', 'core', '') ;
-}
-if (isset ($GLOBALS['sys_forum_return_domain'])) {
forge_define_config_item ('forum_return_domain', 'core', $GLOBALS['sys_forum_return_domain']) ;
- forge_define_config_item ('use_jabber', 'core', $GLOBALS['sys_use_jabber']) ;
- forge_set_config_item_bool ('use_jabber', 'core') ;
- forge_define_config_item ('jabber_host', 'core', $GLOBALS['sys_jabber_server']) ;
- forge_define_config_item ('jabber_port', 'core', $GLOBALS['sys_jabber_port']) ;
- forge_define_config_item ('jabber_user', 'core', $GLOBALS['sys_jabber_user']) ;
- forge_define_config_item ('jabber_password', 'core', isset($GLOBALS['sys_jabber_pass']) ? $GLOBALS['sys_jabber_pass'] : '') ;
-} else {
- forge_define_config_item ('forum_return_domain', 'core', '') ;
-}
-if (isset ($GLOBALS['sys_ldap_host'])) {
forge_define_config_item ('ldap_host', 'core', $GLOBALS['sys_ldap_host']) ;
-} else {
- forge_define_config_item ('ldap_host', 'core', '') ;
-}
-if (isset ($GLOBALS['sys_ldap_port'])) {
forge_define_config_item ('ldap_port', 'core', $GLOBALS['sys_ldap_port']) ;
-} else {
- forge_define_config_item ('ldap_port', 'core', '') ;
-}
-if (isset ($GLOBALS['sys_ldap_version'])) {
forge_define_config_item ('ldap_version', 'core', $GLOBALS['sys_ldap_version']) ;
-} else {
- forge_define_config_item ('ldap_version', 'core', 3) ;
-}
-if (isset ($GLOBALS['sys_ldap_base_dn'])) {
forge_define_config_item ('ldap_base_dn', 'core', $GLOBALS['sys_ldap_base_dn']) ;
-} else {
- forge_define_config_item ('ldap_base_dn', 'core', '') ;
-}
-if (isset ($GLOBALS['sys_ldap_bind_dn'])) {
forge_define_config_item ('ldap_bind_dn', 'core', $GLOBALS['sys_ldap_bind_dn']) ;
-} else {
- forge_define_config_item ('ldap_bind_dn', 'core', '') ;
-}
-if (isset ($GLOBALS['sys_ldap_admin_dn'])) {
forge_define_config_item ('ldap_admin_dn', 'core', $GLOBALS['sys_ldap_admin_dn']) ;
-} else {
- forge_define_config_item ('ldap_admin_dn', 'core', '') ;
-}
-forge_define_config_item ('ldap_password', 'core', isset($GLOBALS['sys_ldap_passwd']) ? $GLOBALS['sys_ldap_passwd'] : '') ;
-if (isset ($GLOBALS['sys_news_group'])) {
+ forge_define_config_item ('ldap_password', 'core', isset($GLOBALS['sys_ldap_passwd']) ? $GLOBALS['sys_ldap_passwd'] : '') ;
forge_define_config_item ('news_group', 'core', $GLOBALS['sys_news_group']) ;
-} else {
- forge_define_config_item ('news_group', 'core', 2) ;
-}
-if (isset ($GLOBALS['sys_stats_group'])) {
forge_define_config_item ('stats_group', 'core', $GLOBALS['sys_stats_group']) ;
-} else {
- forge_define_config_item ('stats_group', 'core', 3) ;
-}
-if (isset ($GLOBALS['sys_peer_rating_group'])) {
forge_define_config_item ('peer_rating_group', 'core', $GLOBALS['sys_peer_rating_group']) ;
-} else {
- forge_define_config_item ('peer_rating_group', 'core', 4) ;
-}
-if (isset ($GLOBALS['sys_template_group'])) {
forge_define_config_item ('template_group', 'core', $GLOBALS['sys_template_group']) ;
-} else {
- forge_define_config_item ('template_group', 'core', 5) ;
-}
-if (isset ($GLOBALS['sys_sendmail_path'])) {
forge_define_config_item ('sendmail_path', 'core', $GLOBALS['sys_sendmail_path']) ;
-} else {
- forge_define_config_item ('sendmail_path', 'core', '/usr/sbin/sendmail') ;
-}
-if (isset ($GLOBALS['sys_path_to_mailman'])) {
forge_define_config_item ('mailman_path', 'core', $GLOBALS['sys_path_to_mailman']) ;
-} else {
- forge_define_config_item ('mailman_path', 'core', '') ;
-}
-if (isset ($GLOBALS['sys_path_to_jpgraph'])) {
forge_define_config_item ('jpgraph_path', 'core', $GLOBALS['sys_path_to_jpgraph']) ;
-} else {
- forge_define_config_item ('jpgraph_path', 'core', '') ;
-}
-if (isset ($GLOBALS['sys_account_manager_type'])) {
forge_define_config_item ('account_manager_type', 'core', $GLOBALS['sys_account_manager_type']) ;
-} else {
- forge_define_config_item ('account_manager_type', 'core', '') ;
-}
-if (isset ($GLOBALS['unix_cipher'])) {
forge_define_config_item ('unix_cipher', 'core', $GLOBALS['unix_cipher']) ;
-} else {
- forge_define_config_item ('unix_cipher', 'core', '') ;
-}
-if (isset ($GLOBALS['homedir_prefix'])) {
forge_define_config_item ('homedir_prefix', 'core', $GLOBALS['homedir_prefix']) ;
-} else {
- forge_define_config_item ('homedir_prefix', 'core', '') ;
-}
-if (isset ($GLOBALS['groupdir_prefix'])) {
forge_define_config_item ('groupdir_prefix', 'core', $GLOBALS['groupdir_prefix']) ;
-} else {
- forge_define_config_item ('groupdir_prefix', 'core', '') ;
-}
-if (isset ($GLOBALS['sys_urlroot'])) {
forge_define_config_item ('url_root', 'core', $GLOBALS['sys_urlroot']) ;
-} else {
- forge_define_config_item ('url_root', 'core', '') ;
-}
-if (isset ($GLOBALS['sys_urlprefix'])) {
forge_define_config_item ('url_prefix', 'core', $GLOBALS['sys_urlprefix']) ;
-} else {
- forge_define_config_item ('url_prefix', 'core', '') ;
-}
-if (isset ($GLOBALS['sys_images_url'])) {
forge_define_config_item ('images_url', 'core', $GLOBALS['sys_images_url']) ;
-} else {
- forge_define_config_item ('images_url', 'core', '') ;
-}
-if (isset ($GLOBALS['sys_images_secure_url'])) {
forge_define_config_item ('images_secure_url', 'core', $GLOBALS['sys_images_secure_url']) ;
-} else {
- forge_define_config_item ('images_secure_url', 'core', '') ;
-}
-if (isset ($GLOBALS['sys_admin_email'])) {
forge_define_config_item ('admin_email', 'core', $GLOBALS['sys_admin_email']) ;
-} else {
- forge_define_config_item ('admin_email', 'core', '') ;
-}
-if (isset ($GLOBALS['sys_session_key'])) {
forge_define_config_item ('session_key', 'core', $GLOBALS['sys_session_key']) ;
-} else {
- forge_define_config_item ('session_key', 'core', '') ;
-}
-if (isset ($GLOBALS['sys_session_expire'])) {
forge_define_config_item ('session_expire', 'core', $GLOBALS['sys_session_expire']) ;
-} else {
- forge_define_config_item ('session_expire', 'core', 0) ;
-}
-if (isset ($GLOBALS['sys_show_source'])) {
forge_define_config_item ('show_source', 'core', $GLOBALS['sys_show_source']) ;
-} else {
- forge_define_config_item ('show_source', 'core', true) ;
-}
-forge_set_config_item_bool ('show_source', 'core') ;
-if (isset ($GLOBALS['default_trove_cat'])) {
+ forge_set_config_item_bool ('show_source', 'core') ;
forge_define_config_item ('default_trove_cat', 'core', $GLOBALS['default_trove_cat']) ;
-} else {
- forge_define_config_item ('default_trove_cat', 'core', 18) ;
-}
-if (isset ($GLOBALS['sys_require_accept_conditions'])) {
forge_define_config_item ('user_registration_accept_conditions', 'core', $GLOBALS['sys_require_accept_conditions']);
-} else {
- forge_define_config_item ('user_registration_accept_conditions', 'core', false);
+ forge_set_config_item_bool ('user_registration_accept_conditions', 'core') ;
+ forge_define_config_item ('compression_method', 'core', 'gzip') ;
}
-forge_set_config_item_bool ('user_registration_accept_conditions', 'core') ;
// Arch plugin
if (file_exists ($gfconfig.'plugins/scmarch/config.php')) {
require_once $gfconfig.'plugins/scmarch/config.php' ;
-
+
forge_define_config_item ('default_server', 'scmarch', $default_arch_server) ;
if (isset ($arch_root)) {
forge_define_config_item ('repos_path', 'scmarch', $arch_root) ;
// Bazaar plugin
if (file_exists ($gfconfig.'plugins/scmbzr/config.php')) {
require_once $gfconfig.'plugins/scmbzr/config.php' ;
-
+
forge_define_config_item ('default_server', 'scmbzr', $default_bzr_server) ;
if (isset ($bzr_root)) {
forge_define_config_item ('repos_path', 'scmbzr', $bzr_root) ;
// CVS plugin
if (file_exists ($gfconfig.'plugins/scmcvs/config.php')) {
require_once $gfconfig.'plugins/scmcvs/config.php' ;
-
+
forge_define_config_item ('default_server', 'scmcvs', $default_cvs_server) ;
if (isset ($cvs_root)) {
forge_define_config_item ('repos_path', 'scmcvs', $cvs_root) ;
// Darcs plugin
if (file_exists ($gfconfig.'plugins/scmdarcs/config.php')) {
require_once $gfconfig.'plugins/scmdarcs/config.php' ;
-
+
forge_define_config_item ('default_server', 'scmdarcs', $default_darcs_server) ;
if (isset ($darcs_root)) {
forge_define_config_item ('repos_path', 'scmdarcs', $darcs_root) ;
// Git plugin
if (file_exists ($gfconfig.'plugins/scmgit/config.php')) {
require_once $gfconfig.'plugins/scmgit/config.php' ;
-
+
forge_define_config_item ('default_server', 'scmgit', $default_git_server) ;
if (isset ($git_root)) {
forge_define_config_item ('repos_path', 'scmgit', $git_root) ;
// Mercurial plugin
if (file_exists ($gfconfig.'plugins/scmhg/config.php')) {
require_once $gfconfig.'plugins/scmhg/config.php' ;
-
+
forge_define_config_item ('default_server', 'scmhg', $default_hg_server) ;
if (isset ($hg_root)) {
forge_define_config_item ('repos_path', 'scmhg', $hg_root) ;
// Subversion plugin
if (file_exists ($gfconfig.'plugins/scmsvn/config.php')) {
require_once $gfconfig.'plugins/scmsvn/config.php' ;
-
+
forge_define_config_item ('default_server', 'scmsvn', $default_svn_server) ;
if (isset ($svn_root)) {
forge_define_config_item ('repos_path', 'scmsvn', $svn_root) ;
} else {
forge_define_config_item ('repos_path', 'scmsvn',
- forge_get_config('chroot').'/scmrepos/svn') ;
+ forge_get_config('chroot').'/scmrepos/svn') ;
}
forge_define_config_item ('use_ssh', 'scmsvn', $use_ssh ? 1 : 0) ;
forge_set_config_item_bool ('use_ssl', 'scmsvn') ;
}
-// Mediawiki plugin
-if (isset ($sys_use_mwframe)) {
- forge_define_config_item ('use_frame', 'mediawiki', $sys_use_mwframe ? 1 : 0) ;
- forge_set_config_item_bool ('use_frame', 'mediawiki') ;
-}
-
// Mantis plugin
if (file_exists ($gfconfig.'plugins/mantis/config.php')) {
require_once $gfconfig.'plugins/mantis/config.php' ;
-
+
forge_define_config_item ('server', 'mantis', $serveur_mantis) ;
forge_define_config_item ('db_host', 'mantis', $mantis_db_host) ;
forge_define_config_item ('db_user', 'mantis', $mantis_db_user) ;
exit;
}
+// Use latest rendering engine for IE (bypass compatibility mode)
+if (isset($_SERVER['HTTP_USER_AGENT']) && stripos($_SERVER['HTTP_USER_AGENT'], "msie")) {
+ header("X-UA-Compatible: IE=edge");
+}
+
if (!isset($no_gz_buffer) || !$no_gz_buffer) {
ob_start("ob_gzhandler");
}
// Database access and other passwords when on the web
-function setconfigfromoldsources ($sec, $var, $serv, $env, $glob) {
+function setconfigfromenv ($sec, $var, $serv, $env) {
if (getenv ('SERVER_SOFTWARE')) {
if (function_exists ('apache_request_headers')) {
$headers = apache_request_headers() ;
if (isset ($headers[$serv])) {
forge_define_config_item ($var, $sec,
$headers[$serv]) ;
- return ;
- }
+ return true;
+ }
}
if (isset ($_ENV[$env])) {
forge_define_config_item ($var, $sec,
getenv($env)) ;
- return ;
+ return true;
+ }
+ return false;
+}
+
+function setconfigfromoldsources ($sec, $var, $serv, $env, $glob) {
+ if (setconfigfromenv($sec, $var, $serv, $env)) {
+ return true;
}
if (isset ($GLOBALS[$glob])) {
forge_define_config_item ($var, $sec,
$GLOBALS[$glob]) ;
- return ;
+ return true;
}
+ return false;
}
-if (file_exists ($gfcgfile)) {
+if (isset($gfcgfile) && file_exists ($gfcgfile)) {
require_once $gfcgfile ;
-}
-setconfigfromoldsources ('core', 'database_host',
- 'GForgeDbhost', 'sys_gfdbhost', 'sys_dbhost') ;
-setconfigfromoldsources ('core', 'database_port',
- 'GForgeDbport', 'sys_gfdbport', 'sys_dbport') ;
-setconfigfromoldsources ('core', 'database_name',
- 'GForgeDbname', 'sys_gfdbname', 'sys_dbname') ;
-setconfigfromoldsources ('core', 'database_user',
- 'GForgeDbuser', 'sys_gfdbuser', 'sys_dbuser') ;
-setconfigfromoldsources ('core', 'database_password',
- 'GForgeDbpasswd', 'sys_gfdbpasswd', 'sys_dbpasswd') ;
-setconfigfromoldsources ('core', 'ldap_password',
- 'GForgeLdapPasswd', 'sys_gfldap_passwd', NULL) ;
-
-forge_define_config_item ('source_path', 'core', $fusionforge_basedir) ;
-forge_define_config_item ('data_path', 'core', '/var/lib/gforge') ;
-forge_define_config_item ('chroot', 'core', '$core/data_path/chroot') ;
-forge_define_config_item ('config_path', 'core', '/etc/gforge') ;
-
-require_once $gfcommon.'include/config-vars.php';
+ setconfigfromoldsources ('core', 'database_host',
+ 'GForgeDbhost', 'sys_gfdbhost', 'sys_dbhost') ;
+ setconfigfromoldsources ('core', 'database_port',
+ 'GForgeDbport', 'sys_gfdbport', 'sys_dbport') ;
+ setconfigfromoldsources ('core', 'database_name',
+ 'GForgeDbname', 'sys_gfdbname', 'sys_dbname') ;
+ setconfigfromoldsources ('core', 'database_user',
+ 'GForgeDbuser', 'sys_gfdbuser', 'sys_dbuser') ;
+ setconfigfromoldsources ('core', 'database_password',
+ 'GForgeDbpasswd', 'sys_gfdbpasswd', 'sys_dbpasswd') ;
+ setconfigfromoldsources ('core', 'ldap_password',
+ 'GForgeLdapPasswd', 'sys_gfldap_passwd', NULL) ;
+ setconfigfromoldsources ('core', 'session_key',
+ 'GForgeSessionKey', 'sys_session_key', NULL) ;
- setconfigfromoldsources ('core', 'jabber_password',
- 'GForgeJabberPasswd', 'sys_gfjabber_pass', NULL) ;
+
+ forge_define_config_item ('source_path', 'core', $fusionforge_basedir) ;
+ forge_define_config_item ('data_path', 'core', '/var/lib/gforge') ;
+ forge_define_config_item ('chroot', 'core', '$core/data_path/chroot') ;
+ forge_define_config_item ('config_path', 'core', '/etc/gforge') ;
+
+ require_once $gfcommon.'include/config-vars.php';
+} else {
+ setconfigfromenv ('core', 'database_host',
+ 'GForgeDbhost', 'sys_gfdbhost') ;
+ setconfigfromenv ('core', 'database_port',
+ 'GForgeDbport', 'sys_gfdbport') ;
+ setconfigfromenv ('core', 'database_name',
+ 'GForgeDbname', 'sys_gfdbname') ;
+ setconfigfromenv ('core', 'database_user',
+ 'GForgeDbuser', 'sys_gfdbuser') ;
+ setconfigfromenv ('core', 'database_password',
+ 'GForgeDbpasswd', 'sys_gfdbpasswd') ;
+ setconfigfromenv ('core', 'ldap_password',
+ 'GForgeLdapPasswd', 'sys_gfldap_passwd') ;
- setconfigfromenv ('core', 'jabber_password',
- 'GForgeJabberPasswd', 'sys_gfjabber_pass') ;
+ setconfigfromenv ('core', 'session_key',
+ 'GForgeSessionKey', 'sys_session_key') ;
+}
forge_read_config_file ($gfconfig.'/config.ini') ;
forge_read_config_dir ($gfconfig.'/config.ini.d/') ;
forge_set_config_item_bool ('sysdebug_backtraces', 'core') ;
forge_define_config_item ('sysdebug_ignored', 'core', 'false') ;
forge_set_config_item_bool ('sysdebug_ignored', 'core') ;
+forge_define_config_item ('sysdebug_dberrors', 'core', 'true') ;
+forge_set_config_item_bool ('sysdebug_dberrors', 'core') ;
forge_define_config_item ('sysdebug_dbquery', 'core', 'false') ;
forge_set_config_item_bool ('sysdebug_dbquery', 'core') ;
forge_define_config_item ('sysdebug_xmlstarlet', 'core', 'false') ;
forge_set_config_item_bool ('sysdebug_xmlstarlet', 'core') ;
-forge_define_config_item ('sysdebug_akelos', 'core', 'false') ;
-forge_set_config_item_bool ('sysdebug_akelos', 'core') ;
// Load extra func to add extras func like debug
$sysdebug_enable = forge_get_config('sysdebug_enable');
if ($sysdebug_enable && getenv('SERVER_SOFTWARE')) {
require $gfcommon.'include/extras-debug.php';
} else {
+ $sysdebug_dberrors = false;
$sysdebug_dbquery = false;
function sysdebug_off($hdr=false, $replace=true, $resp=false) {
require_once $gfcommon.'include/Error.class.php';
// Database abstraction
-require_once $gfcommon.'include/database-pgsql.php';
+// From here database is required
+if (forge_get_config('database_name') != "") {
+ require_once $gfcommon.'include/database-pgsql.php';
-// Authentication and access control
-require_once $gfcommon.'include/session.php';
-require_once $gfcommon.'include/RBACEngine.class.php';
+ // Authentication and access control
+ require_once $gfcommon.'include/session.php';
+ require_once $gfcommon.'include/RBACEngine.class.php';
-// System library
-require_once $gfcommon.'include/System.class.php';
-forge_define_config_item('account_manager_type', 'core', 'UNIX') ;
-require_once $gfcommon.'include/system/'.forge_get_config('account_manager_type').'.class.php';
-$amt = forge_get_config('account_manager_type') ;
-$SYS = new $amt();
+ // System library
+ require_once $gfcommon.'include/System.class.php';
+ forge_define_config_item('account_manager_type', 'core', 'UNIX') ;
+ require_once $gfcommon.'include/system/'.forge_get_config('account_manager_type').'.class.php';
+ $amt = forge_get_config('account_manager_type') ;
+ $SYS = new $amt();
-// User-related classes and functions
-require_once $gfcommon.'include/User.class.php';
+ // User-related classes and functions
+ require_once $gfcommon.'include/User.class.php';
-// Project-related classes and functions
-require_once $gfcommon.'include/Group.class.php';
+ // Project-related classes and functions
+ require_once $gfcommon.'include/Group.class.php';
-// Permission-related functions
-require_once $gfcommon.'include/Permission.class.php';
+ // Permission-related functions
+ require_once $gfcommon.'include/Permission.class.php';
-// Plugins subsystem
-require_once $gfcommon.'include/Plugin.class.php' ;
-require_once $gfcommon.'include/PluginManager.class.php' ;
+ // Plugins subsystem
+ require_once $gfcommon.'include/Plugin.class.php' ;
+ require_once $gfcommon.'include/PluginManager.class.php' ;
-// SCM-specific plugins subsystem
-require_once $gfcommon.'include/SCMPlugin.class.php' ;
+ // SCM-specific plugins subsystem
+ require_once $gfcommon.'include/SCMPlugin.class.php' ;
-if (getenv ('FUSIONFORGE_NO_PLUGINS') != 'true') {
- setup_plugin_manager () ;
-}
+ // Authentication-specific plugins subsystem
+ require_once $gfcommon.'include/AuthPlugin.class.php' ;
-ini_set('date.timezone', forge_get_config ('default_timezone'));
+ if (getenv ('FUSIONFORGE_NO_PLUGINS') != 'true') {
+ setup_plugin_manager () ;
+ }
- // Jabber subsystem
- if (forge_get_config('use_jabber')) {
- require_once $gfcommon.'include/Jabber.class.php';
- }
-
-if (isset($_SERVER['SERVER_SOFTWARE'])) { // We're on the web
- // Detect upload larger that upload allowed size.
- if ( $_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST) &&
- empty($_FILES) && $_SERVER['CONTENT_LENGTH'] > 0 )
- {
- $displayMaxSize = ini_get('post_max_size');
+ ini_set('date.timezone', forge_get_config ('default_timezone'));
- switch ( substr($displayMaxSize,-1) )
+ if (isset($_SERVER['SERVER_SOFTWARE'])) { // We're on the web
+ // Detect upload larger that upload allowed size.
+ if ( $_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST) &&
+ empty($_FILES) && $_SERVER['CONTENT_LENGTH'] > 0 )
{
+ $displayMaxSize = ini_get('post_max_size');
+
+ switch ( substr($displayMaxSize,-1) )
+ {
case 'G':
$displayMaxSize = $displayMaxSize * 1024;
case 'M':
$displayMaxSize = $displayMaxSize * 1024;
case 'K':
$displayMaxSize = $displayMaxSize * 1024;
+ }
+
+ $error_msg = sprintf(_('Posted data is too large. %1$s exceeds the maximum size of %2$s'),
+ human_readable_bytes($_SERVER['CONTENT_LENGTH']), human_readable_bytes($displayMaxSize));
}
- $error_msg = sprintf(_('Posted data is too large. %1$s exceeds the maximum size of %2$s'),
- human_readable_bytes($_SERVER['CONTENT_LENGTH']), human_readable_bytes($displayMaxSize));
- }
+ // exit_error() and variants (for the web)
+ require_once $gfcommon.'include/exit.php';
- // exit_error() and variants (for the web)
- require_once $gfcommon.'include/exit.php';
+ // Library to determine browser settings
+ require_once $gfwww.'include/browser.php';
- // Library to determine browser settings
- require_once $gfwww.'include/browser.php';
+ // HTML layout class, may be overriden by the Theme class
+ require_once $gfwww.'include/Layout.class.php';
- // HTML layout class, may be overriden by the Theme class
- require_once $gfwww.'include/Layout.class.php';
+ // Various HTML utilities
+ require_once $gfcommon.'include/utils.php';
- // Various HTML utilities
- require_once $gfcommon.'include/utils.php';
+ // Various HTML libs like button bar, themable
+ require_once $gfwww.'include/html.php';
- // Various HTML libs like button bar, themable
- require_once $gfwww.'include/html.php';
+ // Forms key generation
+ require_once $gfcommon.'include/forms.php';
- // Forms key generation
- require_once $gfcommon.'include/forms.php';
+ // Determine if there's a web session running
+ session_set();
- // Determine if there's a web session running
- session_set();
-
- plugin_hook('after_session_set');
-
- // Mandatory login
- if (!session_loggedin() && forge_get_config ('force_login') == 1 ) {
- $expl_pathinfo = explode('/',getStringFromServer('REQUEST_URI'));
- if (getStringFromServer('REQUEST_URI')!='/' && $expl_pathinfo[1]!='account' && $expl_pathinfo[1]!='export' ) exit_not_logged_in();
- // Show proj* export even if not logged in when force login
- // If not default web project page would be broken
- if ($expl_pathinfo[1]=='export' && !ereg("^proj", $expl_pathinfo[2])) exit_not_logged_in();
- }
+ plugin_hook('after_session_set');
+
+ // Mandatory login
+ if (!session_loggedin() && forge_get_config ('force_login') == 1 ) {
+ $expl_pathinfo = explode('/',getStringFromServer('REQUEST_URI'));
+ if (getStringFromServer('REQUEST_URI')!='/' && $expl_pathinfo[1]!='account' && $expl_pathinfo[1]!='export' && $expl_pathinfo[1]!='plugins') exit_not_logged_in();
+ // Show proj* export even if not logged in when force login
+ // If not default web project page would be broken
+ if ($expl_pathinfo[1]=='export' && !preg_match('/^proj/', $expl_pathinfo[2])) exit_not_logged_in();
+ // We must let auth plugins go further
+ if ($expl_pathinfo[1]=='plugins' && !preg_match('/^auth/', $expl_pathinfo[2])) exit_not_logged_in();
+ }
- // Insert this page view into the database
- require_once $gfwww.'include/logger.php';
-
- // If logged in, set up a $LUSER var referencing
- // the logged in user's object
- // and setup theme
- if (session_loggedin()) {
- $LUSER =& session_get_user();
- header ('Cache-Control: private');
- require_once forge_get_config('themes_root').'/'.$LUSER->setUpTheme().'/Theme.class.php';
- } else {
- require_once forge_get_config('themes_root').'/'.forge_get_config('default_theme').'/Theme.class.php';
+ // Insert this page view into the database
+ require_once $gfcommon.'include/logger.php';
+
+ // If logged in, set up a $LUSER var referencing
+ // the logged in user's object
+ // and setup theme
+ if (session_loggedin()) {
+ $LUSER =& session_get_user();
+ $use_tooltips = $LUSER->usesTooltips();
+ header ('Cache-Control: private');
+ $x_theme = $LUSER->setUpTheme();
+ } else {
+ $use_tooltips = 1;
+ $x_theme = forge_get_config('default_theme');
+ }
+ require_once forge_get_config('themes_root').'/'.$x_theme.'/Theme.class.php';
+ $HTML = new Theme () ;
+ $HTML->_theme = $x_theme;
+ unset($x_theme);
+ } else { // Script run from cron or a command line
+ require_once $gfcommon.'include/squal_exit.php';
}
+
+ // Determine locale
+ require_once $gfcommon.'include/gettext.php';
+ require_once $gfcommon.'include/group_section_texts.php';
+
setup_tz_from_context();
- $HTML = new Theme () ;
-} else { // Script run from cron or a command line
- require_once $gfcommon.'include/squal_exit.php';
+ setup_gettext_from_context();
}
-// Determine locale
-require_once $gfcommon.'include/gettext.php';
-require_once $gfcommon.'include/group_section_texts.php';
-
-setup_gettext_from_context();
$feedback = htmlspecialchars(getStringFromRequest('feedback', $feedback));
$error_msg = htmlspecialchars(getStringFromRequest('error_msg', $error_msg));
* FusionForge miscellaneous utils
*
* Copyright 1999-2001, VA Linux Systems, Inc.
- * Copyright 2009-2010, Roland Mas
- * Copyright 2009-2010, Franck Villaume - Capgemini
+ * Copyright 2009-2011, Roland Mas
+ * Copyright 2009-2011, Franck Villaume - Capgemini
* Copyright (c) 2010, 2011, 2012
* Thorsten Glaser <t.glaser@tarent.de>
- * Copyright (C) 2010-2011 Alain Peyrat - Alcatel-Lucent
+ * Copyright 2010-2011, Alain Peyrat - Alcatel-Lucent
+ * Copyright 2013, Franck Villaume - TrivialDev
*
* This file is part of FusionForge. FusionForge is free software;
* you can redistribute it and/or modify it under the terms of the
return true;
}
+function util_strip_unprintable(&$data) {
+ if (is_array($data)) {
+ foreach ($data as $key => &$value) {
+ util_strip_unprintable($value);
+ }
+ }
+ else {
+ $data = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/', '', $data);
+ }
+ return $data;
+}
+
/**
* removeCRLF() - remove any Carriage Return-Line Feed from a string.
* That function is useful to remove the possibility of a CRLF Injection when sending mail
return mb_convert_encoding($str,$charset,"UTF-8");
}
- function util_send_jabber($to,$subject,$body) {
- if (!forge_get_config('use_jabber')) {
- return;
- }
- $JABBER = new Jabber();
- if (!$JABBER->Connect()) {
- echo '<br />Unable to connect';
- return false;
- }
- //$JABBER->SendAuth();
- //$JABBER->AccountRegistration();
- if (!$JABBER->SendAuth()) {
- echo '<br />Auth Failure';
- $JABBER->Disconnect();
- return false;
- //or die("Couldn't authenticate!");
- }
- $JABBER->SendPresence(NULL, NULL, "online");
-
- $body=htmlspecialchars($body);
- $to_arr=explode(',',$to);
- for ($i=0; $i<count($to_arr); $i++) {
- if ($to_arr[$i]) {
- //echo '<br />Sending Jabbers To: '.$to_arr[$i];
- if (!$JABBER->SendMessage($to_arr[$i], "normal", NULL, array("body" => $body,"subject"=>$subject))) {
- echo '<br />Error Sending to '.$to_arr[$i];
- }
- }
- }
-
- $JABBER->CruiseControl(2);
- $JABBER->Disconnect();
- }
-
/**
* util_handle_message() - a convenience wrapper which sends messages
- * to either a jabber account or email account or both, depending on
- * user preferences
+ * to an email account
*
* @param array array of user_id's from the user table
* @param string subject of the message
* @param string the message body
* @param string a comma-separated list of email address
- * @param string a comma-separated list of jabber address
+ * @param ignored (no longer used)
* @param string From header
*/
- function util_handle_message($id_arr,$subject,$body,$extra_emails='',$extra_jabbers='',$from='') {
+ function util_handle_message($id_arr,$subject,$body,$extra_emails='',$dummy1='',$from='') {
$address=array();
if (count($id_arr) < 1) {
} else {
- $res = db_query_params ('SELECT user_id,jabber_address,email,jabber_only FROM users WHERE user_id = ANY ($1)',
+ $res = db_query_params ('SELECT user_id,email FROM users WHERE user_id = ANY ($1)',
array (db_int_array_to_any_clause ($id_arr))) ;
$rows = db_numrows($res) ;
// Do not send messages to "Nobody"
continue;
}
- //
- // Build arrays of the jabber address
- //
- if (db_result($res,$i,'jabber_address')) {
- $address['jabber_address'][]=db_result($res,$i,'jabber_address');
- if (db_result($res,$i,'jabber_only') != 1) {
- $address['email'][]=db_result($res,$i,'email');
- }
- } else {
- $address['email'][]=db_result($res,$i,'email');
- }
+ $address['email'][]=db_result($res,$i,'email');
}
if (isset ($address['email']) && count($address['email']) > 0) {
$extra_emails=implode($address['email'],',').',' . $extra_emails;
}
- if (isset ($address['jabber_address']) && count($address['jabber_address']) > 0) {
- $extra_jabbers=implode($address['jabber_address'],',').','.$extra_jabbers;
- }
}
if ($extra_emails) {
util_send_message('',$subject,$body,$from,$extra_emails);
}
- if ($extra_jabbers) {
- util_send_jabber($extra_jabbers,$subject,$body);
- }
}
/**
return $arr;
}
-/**
- * util_wrap_find_space() - Find the first space in a string
- *
- * @param string The string in which to find the space (must be UTF8!)
- * @param int The number of characters to wrap - Default is 80
- * @returns The position of the first space
- *
- */
-function util_wrap_find_space($string,$wrap) {
- //echo"\n";
- $start=$wrap-5;
- $try=1;
- $found=false;
-
- while (!$found) {
- //find the first space starting at $start
- $pos=@strpos($string,' ',$start);
-
- //if that space is too far over, go back and start more to the left
- if (($pos > ($wrap+5)) || !$pos) {
- $try++;
- $start=($wrap-($try*5));
- //if we've gotten so far left , just truncate the line
- if ($start<=20) {
- while ($wrap >= 1) {
- $code = ord(substr($string,$wrap,1));
- if ($code <= 0x7F ||
- $code >= 0xC0) {
- //Here is single byte character
- //or head of multi byte character
- return $wrap;
- }
- //Do not break multi byte character
- $wrap--;
- }
- return $wrap;
- }
- $found=false;
- } else {
- $found=true;
- }
- }
-
- return $pos;
-}
-
/**
* util_line_wrap() - Automatically linewrap text
*
*
*/
function util_line_wrap ($text, $wrap = 80, $break = "\n") {
- $paras = explode("\n", $text);
-
- $result = array();
- $i = 0;
- while ($i < count($paras)) {
- if (strlen($paras[$i]) <= $wrap) {
- $result[] = $paras[$i];
- $i++;
- } else {
- $pos=util_wrap_find_space($paras[$i],$wrap);
-
- $result[] = substr($paras[$i], 0, $pos);
-
- $new = trim(substr($paras[$i], $pos, strlen($paras[$i]) - $pos));
- if ($new != '') {
- $paras[$i] = $new;
- $pos=util_wrap_find_space($paras[$i],$wrap);
- } else {
- $i++;
- }
- }
- }
- return implode($break, $result);
+ return wordwrap($text, $wrap, $break, false);
}
/**
* @returns The HREF'ed URL
*
*/
-function util_make_links ($data='') {
+function util_make_links($data='') {
if(empty($data)) {
return $data;
}
- $lines = explode("\n",$data);
+ $lines = explode("\n", $data);
$newText = "";
- while ( list ($key,$line) = each ($lines)) {
+ while ( list ($key, $line) = each ($lines)) {
// When we come here, we usually have form input
// encoded in entities. Our aim is to NOT include
// angle brackets in the URL
// (RFC2396; http://www.w3.org/Addressing/URL/5.1_Wrappers.html)
$line = str_replace('>', "\1", $line);
- $line = preg_replace( "/([ \t]|^)www\./i", " http://www.", $line);
- $text = preg_replace( "/([[:alnum:]]+):\/\/([^[:space:]<\1]*)([[:alnum:]#?\/&=])/i",
+ $line = preg_replace("/([ \t]|^)www\./i", " http://www.", $line);
+ $line = preg_replace("/([[:alnum:]]+):\/\/([^[:space:]<\1]*)([[:alnum:]#?\/&=])/i",
"<a href=\"\\1://\\2\\3\" target=\"_new\">\\1://\\2\\3</a>", $line);
- $text = preg_replace(
+ $line = preg_replace(
"/([[:space:]]|^)(([a-z0-9_]|\\-|\\.)+@([^[:space:]]*)([[:alnum:]-]))/i",
"\\1<a href=\"mailto:\\2\" target=\"_new\">\\2</a>",
- $text
+ $line
);
- $text = str_replace("\1", '>', $text);
- $newText .= $text;
+ $line = str_replace("\1", '>', $line);
+ $newText .= $line;
}
return $newText;
}
*
*/
function show_priority_colors_key() {
- echo '<p /><strong> '._('Priority Colors').':</strong><br />
-
- <table border="0"><tr>';
-
+ echo '<p><strong> '._('Priority Colors')._(':').'</strong>';
for ($i=1; $i<6; $i++) {
- echo '
- <td class="priority'.$i.'">'.$i.'</td>';
+ echo ' <span class="priority'.$i.'">'.$i.'</span>';
}
- echo '</tr></table>';
+ echo '</p>';
}
/**
* @param array An array of boxes to be pre-checked
*
*/
-function utils_buildcheckboxarray($options,$name,$checked_array) {
- $option_count=count($options);
- $checked_count=count($checked_array);
+function utils_buildcheckboxarray($options, $name, $checked_array) {
+ $option_count = count($options);
+ $checked_count = count($checked_array);
- for ($i=1; $i<=$option_count; $i++) {
+ for ($i = 1; $i <= $option_count; $i++) {
echo '
<br /><input type="checkbox" name="'.$name.'" value="'.$i.'"';
- for ($j=0; $j<$checked_count; $j++) {
+ for ($j=0; $j < $checked_count; $j++) {
if ($i == $checked_array[$j]) {
echo ' checked';
}
* Be sure to include HTL_Graphs.php before using this function
*
* @author Tim Perdue tperdue@valinux.com
- * @param int The databse result set ID
- * @param string The title of the graph
+ * @param int The databse result set ID
+ * @param string The title of the graph
*
*/
function GraphResult($result, $title) {
- $rows=db_numrows($result);
+ $rows = db_numrows($result);
if ((!$result) || ($rows < 1)) {
echo 'None Found.';
} else {
- $names=array();
- $values=array();
+ $names = array();
+ $values = array();
- for ($j=0; $j<db_numrows($result); $j++) {
+ for ($j=0; $j < db_numrows($result); $j++) {
if (db_result($result, $j, 0) != '' && db_result($result, $j, 1) != '' ) {
- $names[$j]= db_result($result, $j, 0);
- $values[$j]= db_result($result, $j, 1);
+ $names[$j] = db_result($result, $j, 0);
+ $values[$j] = db_result($result, $j, 1);
}
}
/*
This is another function detailed below
*/
- GraphIt($names,$values,$title);
+ GraphIt($names, $values, $title);
}
}
* GraphIt() - Build a graph
*
* @author Tim Perdue tperdue@valinux.com
- * @param array An array of names
- * @param array An array of values
- * @param string The title of the graph
+ * @param array An array of names
+ * @param array An array of values
+ * @param string The title of the graph
*
*/
function GraphIt($name_string, $value_string, $title) {
- GLOBAL $HTML;
+ global $HTML;
- $counter=count($name_string);
+ $counter = count($name_string);
/*
Can choose any color you wish
*/
- $bars=array();
+ $bars = array();
for ($i = 0; $i < $counter; $i++) {
- $bars[$i]=$HTML->COLOR_LTBACK1;
+ $bars[$i] = $HTML->COLOR_LTBACK1;
}
- $counter=count($value_string);
+ $counter = count($value_string);
/*
Figure the max_value passed in, so scale can be determined
*/
- $max_value=0;
+ $max_value = 0;
for ($i = 0; $i < $counter; $i++) {
if ($value_string[$i] > $max_value) {
- $max_value=$value_string[$i];
+ $max_value = $value_string[$i];
}
}
if ($max_value < 1) {
- $max_value=1;
+ $max_value = 1;
}
/*
I want my graphs all to be 800 pixels wide, so that is my divisor
*/
- $scale=(400/$max_value);
+ $scale = (400/$max_value);
/*
I create a wrapper table around the graph that holds the title
*/
- $title_arr=array();
- $title_arr[]=$title;
+ $title_arr = array();
+ $title_arr[] = $title;
echo $GLOBALS['HTML']->listTableTop ($title_arr);
echo '<tr><td>';
This is the actual call to the HTML_Graphs class
*/
- html_graph($name_string,$value_string,$bars,$vals);
+ html_graph($name_string, $value_string, $bars, $vals);
echo '
</td></tr>
$rows = db_numrows($result);
$cols = db_numfields($result);
- echo '<table border="0" width="100%">';
+ echo '<table width="100%">';
/* Create the headers */
$headersCellData = array();
* @param char Separator
* @returns array Array of invalid e-mail addresses (if empty, all addresses are OK)
*/
-function validate_emails ($addresses, $separator=',') {
+function validate_emails($addresses, $separator=',') {
if (strlen($addresses) == 0) return array();
$emails = explode($separator, $addresses);
* @returns true on success/false on error
*
*/
-function util_is_valid_filename ($file) {
+function util_is_valid_filename($file) {
//bad char test
$invalidchars = preg_replace("/[-A-Z0-9+_\. ~]/i","",$file);
* @returns true on success/false on failur
*
*/
-function valid_hostname ($hostname = "xyz") {
+function valid_hostname($hostname = "xyz") {
//bad char test
$invalidchars = preg_replace("/[-A-Z0-9\.]/i","",$hostname);
* @param array labels strings associated to each 2^10 or
* 10^3(base10==true) multiple of base units
*/
-function human_readable_bytes ($bytes, $base10=false, $round=0, $labels=array(' bytes', ' KB', ' MB', ' GB')) {
- if ($bytes <= 0 || !is_array($labels) || (count($labels) <= 0)) {
- return null;
- }
- $step = $base10 ? 3 : 10;
- $base = $base10 ? 10 : 2;
+function human_readable_bytes ($bytes, $base10=false, $round=0, $labels=array()) {
+ if ($bytes == 0) {
+ return "0";
+ }
+ if ($bytes < 0) {
+ return "-" . human_readable_bytes(-$bytes, $base10, $round);
+ }
+ if ($base10) {
+ $labels = array(_('bytes'), _('kB'), _('MB'), _('GB'), _('TB'));
+ $step = 3;
+ $base = 10;
+ } else {
+ $labels = array(_('bytes'), _('KiB'), _('MiB'), _('GiB'), _('TiB'));
+ $step = 10;
+ $base = 2;
+ }
$log = (int)(log10($bytes)/log10($base));
krsort($labels);
foreach ($labels as $p=>$lab) {
if ($log < $pow) {
continue;
}
- if ($lab == " MB" or $lab == " GB") {
+ if ($lab != _("bytes") and $lab != _("kB") and $lab != _("KiB")) {
$round = 2;
}
- $text = round($bytes/pow($base,$pow),$round).$lab;
+ $text = round($bytes/pow($base,$pow),$round) . " " . $lab;
break;
}
return $text;
* @return string
*/
function util_strip_accents($text) {
- return iconv ('UTF-8', 'US-ASCII//TRANSLIT', $text) ;
+ $find = utf8_decode($text);
+ $find = strtr($find,
+ utf8_decode('àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ'),
+ 'aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY');
+ return utf8_encode($find);
}
/**
*
* @return string
*/
-function normalized_urlprefix () {
+function normalized_urlprefix() {
$prefix = forge_get_config('url_prefix') ;
$prefix = preg_replace ("/^\//", "", $prefix) ;
$prefix = preg_replace ("/\/$/", "", $prefix) ;
}
}
+/**
+ * Construct the base URL http[s]://forge_name[:port]
+ *
+ * @return string base URL
+ */
+function util_make_base_url() {
+ $url = util_url_prefix();
+ $url .= forge_get_config('web_host') ;
+ if (forge_get_config('https_port') && (forge_get_config('https_port') != 443)) {
+ $url .= ":".forge_get_config('https_port') ;
+ }
+ return $url;
+}
+
/**
* Construct full URL from a relative path
*
- * @param string $path
- * @return string URL
+ * @param string $path
+ * @return string URL
*/
-function util_make_url ($path) {
- if (forge_get_config('use_ssl')) {
- $url = "https://" ;
- $url .= forge_get_config('web_host') ;
- if (forge_get_config('https_port') != 443) {
- $url .= ":".forge_get_config('https_port') ;
- }
- } else {
- $url = "http://" ;
- $url .= forge_get_config('web_host') ;
- if (forge_get_config('http_port') != 80) {
- $url .= ":".forge_get_config('http_port') ;
- }
- }
- $url .= util_make_uri ($path) ;
- return $url ;
+function util_make_url($path = '') {
+ $url = util_make_base_url().util_make_uri($path) ;
+ return $url;
+}
+
+/**
+ * Find the relative URL from full URL, removing http[s]://forge_name[:port]
+ *
+ * @param string URL
+ */
+function util_find_relative_referer($url) {
+ $relative_url = str_replace(util_make_base_url(), '', $url);
+ //now remove previous feedback, error_msg or warning_msg
+ $relative_url = preg_replace('/&error_msg=.*&/', '&', $relative_url);
+ $relative_url = preg_replace('/&warning_msg=.*&/', '&', $relative_url);
+ $relative_url = preg_replace('/&feedback=.*&/', '&', $relative_url);
+ $relative_url = preg_replace('/&error_msg=.*/', '', $relative_url);
+ $relative_url = preg_replace('/&warning_msg=.*/', '', $relative_url);
+ $relative_url = preg_replace('/&feedback=.*/', '', $relative_url);
+ return $relative_url;
}
/**
* @param string $path
* @return string URI
*/
-function util_make_uri ($path) {
- $path = preg_replace ('/^\//', '', $path) ;
- $uri = normalized_urlprefix () ;
- $uri .= $path ;
- return $uri ;
+function util_make_uri($path) {
+ $path = preg_replace('/^\//', '', $path);
+ $uri = normalized_urlprefix();
+ $uri .= $path;
+ return $uri;
}
-function util_make_link ($path, $text, $extra_params=false, $absolute=false) {
- $ep = '' ;
+function util_make_link($path, $text, $extra_params = false, $absolute = false) {
+ global $use_tooltips;
+ $ep = '';
if (is_array($extra_params)) {
foreach ($extra_params as $key => $value) {
- $ep .= "$key=\"$value\" ";
+ if ($key != 'title') {
+ $ep .= "$key=\"$value\" ";
+ }
+ if ($key == 'title' && $use_tooltips) {
+ $ep .= "$key=\"$value\" ";
+ }
}
}
if ($absolute) {
* @return string
*/
function util_make_link_u ($username, $user_id,$text) {
- return '<a href="' . util_make_url_u ($username, $user_id) . '">' . $text . '</a>' ;
+ return '<a href="' . util_make_url_u ($username, $user_id) . '">' . $text . '</a>';
}
/**
* @param string $size
* @return string
*/
-function util_display_user($username, $user_id,$text, $size='xs') {
- $hook_params = array();
- $hook_params['username'] = $username;
- $hook_params['user_id'] = $user_id;
- $hook_params['user_link'] = '';
- plugin_hook_by_reference("user_link_with_tooltip", $hook_params);
+function util_display_user($username, $user_id, $text, $size='xs') {
+ // Invoke user_link_with_tooltip plugin
+ $hook_params = array('resource_type' => 'user', 'username' => $username, 'user_id' => $user_id, 'size' => $size, 'user_link' => '');
+ plugin_hook_by_reference('user_link_with_tooltip', $hook_params);
if($hook_params['user_link'] != ''){
return $hook_params['user_link'];
}
+ // If no plugin replaced it, then back to default standard link
+
+ // Invoke user_logo plugin (see gravatar plugin for instance)
$params = array('user_id' => $user_id, 'size' => $size, 'content' => '');
plugin_hook_by_reference('user_logo', $params);
+
$url = '<a href="' . util_make_url_u ($username, $user_id) . '">' . $text . '</a>';
if ($params['content']) {
return $params['content'].$url.'<div class="new_line"></div>';
* @param string $text
* @return string
*/
-function util_make_link_g ($groupame, $group_id,$text) {
- return '<a href="' . util_make_url_g ($groupame, $group_id) . '">' . $text . '</a>' ;
+function util_make_link_g ($groupname, $group_id,$text) {
+ $hook_params =array();
+ $hook_params['resource_type'] = 'group';
+ $hook_params['group_name'] = $groupname;
+ $hook_params['group_id'] = $group_id;
+ $hook_params['link_text'] = $text;
+ $hook_params['group_link'] = '';
+ plugin_hook_by_reference('project_link_with_tooltip', $hook_params);
+ if($hook_params['group_link'] != '') {
+ return $hook_params['group_link'];
+ }
+
+ return '<a href="' . util_make_url_g ($groupname, $group_id) . '">' . $text . '</a>' ;
}
/**
function check_email_available($group, $email, &$response) {
// Check if a mailing list with same name already exists
if ($group->usesMail()) {
- $mlFactory = new MailingListFactory($group);
- if (!$mlFactory || !is_object($mlFactory) || $mlFactory->isError()) {
- $response .= $mlFactory->getErrorMessage();
- return false;
- }
- $mlArray = $mlFactory->getMailingLists();
- if ($mlFactory->isError()) {
- $response .= $mlFactory->getErrorMessage();
- return false;
- }
- for ($j = 0; $j < count($mlArray); $j++) {
- $currentList =& $mlArray[$j];
- if ($email == $currentList->getName()) {
- $response .= _('Error: a mailing list with the same email address already exists.');
+ $mlFactory = new MailingListFactory($group);
+ if (!$mlFactory || !is_object($mlFactory) || $mlFactory->isError()) {
+ $response .= $mlFactory->getErrorMessage();
return false;
}
- }
+ $mlArray = $mlFactory->getMailingLists();
+ if ($mlFactory->isError()) {
+ $response .= $mlFactory->getErrorMessage();
+ return false;
+ }
+ for ($j = 0; $j < count($mlArray); $j++) {
+ $currentList =& $mlArray[$j];
+ if ($email == $currentList->getName()) {
+ $response .= _('Error: a mailing list with the same email address already exists.');
+ return false;
+ }
+ }
}
// Check if a forum with same name already exists
if ($group->usesForum()) {
- $ff = new ForumFactory($group);
- if (!$ff || !is_object($ff) || $ff->isError()) {
- $response .= $ff->getErrorMessage();
- return false;
- }
- $farr = $ff->getForums();
- $prefix = $group->getUnixName() . '-';
- for ($j = 0; $j < count($farr); $j++) {
- if (is_object($farr[$j])) {
- if ($email == $prefix . $farr[$j]->getName()) {
- $response .= _('Error: a forum with the same email address already exists.');
- return false;
+ $ff = new ForumFactory($group);
+ if (!$ff || !is_object($ff) || $ff->isError()) {
+ $response .= $ff->getErrorMessage();
+ return false;
+ }
+ $farr = $ff->getForums();
+ $prefix = $group->getUnixName() . '-';
+ for ($j = 0; $j < count($farr); $j++) {
+ if (is_object($farr[$j])) {
+ if ($email == $prefix . $farr[$j]->getName()) {
+ $response .= _('Error: a forum with the same email address already exists.');
+ return false;
+ }
}
}
}
- }
// Email is available
return true;
}
+/**
+ * Adds the Javascript file to the lits to be used
+ * @param unknown_type $js
+ */
function use_javascript($js) {
return $GLOBALS['HTML']->addJavascript($js);
}
// array_replace_recursive only appeared in PHP 5.3.0
if (!function_exists('array_replace_recursive')) {
+ /**
+ * Replaces elements from passed arrays into the first array recursively
+ * @param array $a1 The array in which elements are replaced.
+ * @param array $a2 The array from which elements will be extracted.
+ * @return Returns an array, or NULL if an error occurs.
+ */
function array_replace_recursive ($a1, $a2) {
$result = $a1 ;
$postfile = (int)(($postmax * 3) / 4);
- if ($postfile < $maxfile)
+ if ($postfile > $maxfile)
$postfile = $maxfile;
return $postfile;
}
+function util_get_compressed_file_extension() {
+ $m = forge_get_config('compression_method');
+ if (preg_match ('/^gzip\b/', $m)) {
+ return '.gz';
+ } elseif (preg_match ('/^bzip2\b/', $m)) {
+ return '.bzip2';
+ } elseif (preg_match ('/^lzma\b/', $m)) {
+ return '.lzma';
+ } elseif (preg_match ('/^xz\b/', $m)) {
+ return '.xz';
+ } elseif (preg_match ('/^cat\b/', $m)) {
+ return '';
+ } else {
+ return '.compressed';
+ }
+}
+
/* return $1 if $1 is set, ${2:-false} otherwise */
function util_ifsetor(&$val, $default = false) {
return (isset($val) ? $val : $default);
}
/**
- * Codendi compatibility code.
- *
- * @deprecated
+ * TODO: Enter description here ...
+ * @param unknown_type $script
+ * @param unknown_type $default_content_type
+ * @return Ambiguous
*/
-function user_is_super_user() {
- return forge_check_global_perm('forge_admin');
+function util_negociate_alternate_content_types($script, $default_content_type) {
+
+ // Invoke plugins' hooks 'script_accepted_types' to discover which alternate content types they would accept for /users/...
+ $hook_params = array();
+ $hook_params['script'] = $script;
+ $hook_params['accepted_types'] = array();
+ plugin_hook_by_reference('script_accepted_types', $hook_params);
+ if (count($hook_params['accepted_types'])) {
+ // By default, text/html is accepted
+ $accepted_types = array($default_content_type);
+ $new_accepted_types = $hook_params['accepted_types'];
+ $accepted_types = array_merge($accepted_types, $new_accepted_types);
+
+ // PEAR::HTTP (for negotiateMimeType())
+ require_once('HTTP.php');
+
+ // negociate accepted content-type depending on the preferred ones declared by client
+ $http=new HTTP();
+ $content_type = $http->negotiateMimeType($accepted_types, false);
+ } else {
+ $content_type = $default_content_type;
+ }
+ return $content_type;
}
/**
* Copyright 1999-2000, Tim Perdue/Sourceforge
* Copyright 2002, Tim Perdue/GForge, LLC
* Copyright 2009, Roland Mas
- * Copyright (C) 2010 Alain Peyrat - Alcatel-Lucent
+ * Copyright 2010, Alain Peyrat - Alcatel-Lucent
+ * Copyright 2011, Thorsten Glaser <t.glaser@tarent.de>
*
* This file is part of FusionForge. FusionForge is free software;
* you can redistribute it and/or modify it under the terms of the
function ProjectTask(&$ProjectGroup, $project_task_id=false, $arr=false) {
$this->Error();
if (!$ProjectGroup || !is_object($ProjectGroup)) {
- $this->setError('ProjectTask:: No Valid ProjectGroup Object');
+ $this->setError('No Valid ProjectGroup Object');
return false;
}
if ($ProjectGroup->isError()) {
- $this->setError('ProjectTask:: '.$ProjectGroup->getErrorMessage());
+ $this->setError($ProjectGroup->getErrorMessage());
return false;
}
$this->ProjectGroup =& $ProjectGroup;
function create($summary,$details,$priority,$hours,$start_date,$end_date,
$category_id,$percent_complete,&$assigned_arr,&$depend_arr,$duration=0,$parent_id=0, $importData = array()) {
$v = new Validator();
- $v->check($summary, "summary");
- $v->check($details, "details");
- $v->check($priority, "priority");
- $v->check($hours, "hours");
- $v->check($start_date, "start date");
- $v->check($end_date, "end date");
- $v->check($category_id, "category");
+ $v->check($summary, _("summary"));
+ $v->check($details, _("details"));
+ $v->check($priority, _("priority"));
+ $v->check($hours, _("hours"));
+ $v->check($start_date, _("start date"));
+ $v->check($end_date, _("end date"));
+ $v->check($category_id, _("category"));
if (!$v->isClean()) {
- $this->setError($v->formErrorMsg("Must include "));
+ $this->setError($v->formErrorMsg(_("Must include ")));
return false;
}
if (!$parent_id) {
}
db_begin();
- $res = db_query_params ('SELECT nextval($1) AS id',
+ $res = db_query_params ('SELECT nextval($1) AS id',
array ('project_task_pk_seq'));
if (!$project_task_id=db_result($res,0,'id')) {
$this->setError( 'Could Not Get Next Project Task ID' );
db_rollback();
return false;
}
-
+
$this->data_array['project_task_id']=$project_task_id;
-
+
$result = db_query_params ('INSERT INTO project_task (project_task_id,group_project_id,created_by,summary,details,start_date,end_date,status_id,category_id,priority,percent_complete,hours,duration,parent_id) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14)',
array ($project_task_id,
$this->ProjectGroup->getID(),
$hours,
$duration,
$parent_id)) ;
-
+
if (!$result || db_affected_rows($result) < 1) {
- $this->setError('ProjectTask::create() Posting Failed '.db_error());
+ $this->setError('Posting Failed '.db_error());
db_rollback();
return false;
}
array ($project_task_id,
$this->ProjectGroup->getID())) ;
if (!$res || db_numrows($res) < 1) {
- $this->setError('ProjectTask::fetchData() Invalid Task ID'.db_error());
+ $this->setError('Invalid Task ID'.db_error());
return false;
}
$this->data_array = db_fetch_array($res);
function getSubmittedRealName() {
return $this->data_array['realname'];
}
-
+
/**
* getDuration - the duration of the task.
*
function getDuration() {
return $this->data_array['duration'];
}
-
+
/**
* getParentID - the task_id of the parent task, if any.
*
function getParentID() {
return $this->data_array['parent_id'];
}
-
+
/**
* getSubmittedUnixName - get the unix name of the person who created this task.
*
function getLastModifiedDate() {
return $this->data_array['last_modified_date'];
}
-
+
/**
- * setExternalID - set a row in project_task_external_order which stores
+ * setExternalID - set a row in project_task_external_order which stores
* an id, for example an ID generated by MS Project, which needs to be restored later
*/
function setExternalID($id) {
array ($id,
$this->getID())) ;
if (db_affected_rows($res) < 1) {
- $res = db_query_params ('INSERT INTO project_task_external_order (project_task_id,external_id) VALUES ($1, $2)',
+ $res = db_query_params ('INSERT INTO project_task_external_order (project_task_id,external_id) VALUES ($1, $2)',
array ($this->getID(),
$id)) ;
}
function getRelatedArtifacts() {
if (!$this->relatedartifacts) {
$this->relatedartifacts=
- db_query_params ('SELECT agl.group_id,agl.name,agl.group_artifact_id,a.artifact_id,a.open_date,a.summary
- FROM artifact_group_list agl, artifact a
+ db_query_params ('SELECT agl.group_id,agl.name,agl.group_artifact_id,a.artifact_id,a.open_date,a.summary,ast.status_name
+ FROM artifact_group_list agl, artifact a, artifact_status ast
WHERE a.group_artifact_id=agl.group_artifact_id
- AND EXISTS (SELECT artifact_id FROM project_task_artifact
+ AND ast.id=a.status_id
+ AND EXISTS (SELECT artifact_id FROM project_task_artifact
WHERE artifact_id=a.artifact_id
AND project_task_id=$1)',
array ($this->getID())) ;
if ($art_array[$i] < 1) {
continue;
}
- $res = db_query_params ('INSERT INTO project_task_artifact (project_task_id,artifact_id) VALUES ($1,$2)',
+ $res = db_query_params ('INSERT INTO project_task_artifact (project_task_id,artifact_id) VALUES ($1,$2)',
array ($this->getID(),
$art_array[$i])) ;
if (!$res) {
// May not yet have an ID, if we are creating a NEW task
//
if ($this->getID()) {
- return db_query_params ('SELECT project_task_id,summary
- FROM project_task
+ return db_query_params ('SELECT project_task_id,summary
+ FROM project_task
WHERE group_project_id=$1
AND project_task_id <> $2
ORDER BY project_task_id DESC',
array ($this->ProjectGroup->getID(),
$this->getID())) ;
} else {
- return db_query_params ('SELECT project_task_id,summary
- FROM project_task
+ return db_query_params ('SELECT project_task_id,summary
+ FROM project_task
WHERE group_project_id=$1
ORDER BY project_task_id DESC',
array ($this->ProjectGroup->getID())) ;
* @return database result set.
*/
function getHistory() {
- return db_query_params ('SELECT *
- FROM project_history_user_vw
+ return db_query_params ('SELECT *
+ FROM project_history_user_vw
WHERE project_task_id=$1
ORDER BY mod_date DESC',
array ($this->getID())) ;
*
* @return database result set.
*/
- function getMessages() {
- return db_query_params ('SELECT *
- FROM project_message_user_vw
+ function getMessages($asc=false) {
+ return db_query_params ('SELECT *
+ FROM project_message_user_vw
WHERE project_task_id=$1
- ORDER BY postdate DESC',
+ ORDER BY postdate ' . ($asc ? 'ASC' : 'DESC'),
array ($this->getID())) ;
}
if ($this->getDetails() == htmlspecialchars($message)) {
return true;
}
-
- $res = db_query_params ('SELECT * FROM project_messages
+ $res = db_query_params ('SELECT * FROM project_messages
WHERE project_task_id=$1
AND body=$2',
array ($this->getID(),
$uid,
$time)) ;
if (!$res || db_affected_rows($res) < 1) {
- $this->setError('AddMessage():: '.db_error());
+ $this->setError(db_error());
return false;
} else {
return true;
return false;
}
- $res = db_query_params ('SELECT is_dependent_on_task_id AS id
- FROM project_dependencies
+ $res = db_query_params ('SELECT is_dependent_on_task_id AS id
+ FROM project_dependencies
WHERE project_task_id=$1',
array ($depend_on_id)) ;
$rows=db_numrows($res);
function setDependentOn(&$arr_) {
//printr($arr_,'setDependentOn entry');
//
-// IMPORTANT - MUST VERIFY NO CIRCULAR DEPENDENCY!!
+// IMPORTANT - MUST VERIFY NO CIRCULAR DEPENDENCY!!
//
if (!$arr_ || empty($arr_)) {
$arr_=array('100'=>PM_LINK_DEFAULT);
$del_arr = array_values (array_diff ($arr2, $arr));
//echo "del arr: ".print_r($del_arr);
for ($i=0; $i<count($del_arr); $i++) {
- db_query_params ('DELETE FROM project_dependencies
+ db_query_params ('DELETE FROM project_dependencies
WHERE project_task_id=$1
AND is_dependent_on_task_id=$2',
array ($this->getID(),
$del_arr[$i])) ;
if (db_error()) {
- $this->setError('setDependentOn()-1:: '.db_error());
+ $this->setError(db_error());
return false;
}
}
$add_arr[$i],
$lnk)) ;
if (db_error()) {
- $this->setError('setDependentOn()-2:: '.db_error().$sql);
+ $this->setError(db_error());
return false;
}
}
}
/**
- * convertDependentOn - converts a regular array of dependencies, such
- * as from a multiple-select-box to an associative array with default
+ * convertDependentOn - converts a regular array of dependencies, such
+ * as from a multiple-select-box to an associative array with default
* link types. Should be called from web code as part of the create/update calls.
* Here we are converting an array like array(1,5,9,77) to array(1=>SS,5=>SF,9=>FS,77=>SS)
*/
} else {
//else create with default link type
$new[$arr[$i]]=PM_LINK_DEFAULT;
- }
+ }
}
return $new;
}
/**
* getDependentOn - get an array of project_task_id's that you are dependent on.
*
- * @return array The array of project_task_id's in this format:
+ * @return array The array of project_task_id's in this format:
* array($id=>$link_type,id2=>link_type2).
*/
function getDependentOn() {
$arr2 = $this->getAssignedTo();
$this->assignedto =& $arr;
- //If no one is assigned, then assign it to "100" - NOBODY
+ // If no one is assigned, then assign it to "100" - NOBODY
if (!$arr || count($arr) < 1 || ((count($arr)==1) && ($arr[0]==''))) {
$arr=array('100');
}
array ($this->getID(),
$del_arr[$i])) ;
if (db_error()) {
- $this->setError('setAssignedTo()-1:: '.db_error());
+ $this->setError(db_error());
return false;
}
}
array ($this->getID(),
$add_arr[$i])) ;
if (db_error()) {
- $this->setError('setAssignedTo()-2:: '.db_error());
+ $this->setError(db_error());
return false;
}
}
$status_id,$category_id,$percent_complete,&$assigned_arr,&$depend_arr,
$new_group_project_id,$duration=0,$parent_id=0) {
$has_changes = false; // if any of the values passed is different from
-
- $arrChangedAndInNotice = array("details"=>"","summary"=>"",
- "complete"=>"","status"=>"","subproject"=>""); /* includes only
- entries that changed and will be sended by E-Mail (sendNotice()) */
-
+
+ $arrChangedAndInNotice = array(
+ 'details'=>'',
+ 'summary'=>'',
+ 'assigned'=>'',
+ 'complete'=>'',
+ 'status'=>'',
+ 'subproject'=>''
+ );
+
$v = new Validator();
- $v->check($summary, "summary");
- $v->check($priority, "priority");
- $v->check($hours, "hours");
- $v->check($start_date, "start date");
- $v->check($end_date, "end date");
- $v->check($status_id, "status");
- $v->check($category_id, "category");
+ $v->check($summary, _("summary"));
+ $v->check($priority, _("priority"));
+ $v->check($hours, _("hours"));
+ $v->check($start_date, _("start date"));
+ $v->check($end_date, _("end date"));
+ $v->check($status_id, _("status"));
+ $v->check($category_id, _("category"));
if (!$v->isClean()) {
- $this->setError($v->formErrorMsg("Must include "));
+ $this->setError($v->formErrorMsg(_("Must include ")));
return false;
}
if (!$parent_id) {
($this->getStartDate() != $start_date) || ($this->getEndDate() != $end_date) ||
($this->getStatusID() != $status_id) || ($this->getCategoryID() != $category_id) ||
($this->getPercentComplete() != $percent_complete) ) {
-
+
$has_changes = true;
}*/
-
-
+
+
db_begin();
//
return false;
}
}
- if ($this->getStatusID() != $status_id) {
+ if ($this->getStatusID() != $status_id) {
$this->addHistory ('status_id',$this->getStatusID());
$has_changes = true;
$arrChangedAndInNotice['status'] = ">";
}
$old_assigned = $this->getAssignedTo();
- $diff_assigned_array=array_diff($old_assigned, $assigned_arr);
- if (count($diff_assigned_array)>0) {
- for ($tmp=0;$tmp<count($old_assigned);$tmp++) {
- $this->addHistory('assigned_to_id',$old_assigned[$tmp]);
- }
- $has_changes = true;
+ if ($assigned_arr == '' || !$assigned_arr) {
+ $assigned_arr = array();
+ $assigned_arr[0] = 100;
+ }
+ $removed=array_diff($old_assigned, $assigned_arr);
+ $added=array_diff($assigned_arr, $old_assigned);
+ if (count($removed)>0 || count($added)>0) {
+ $assigned = array();
+ foreach ($old_assigned as $user_id) {
+ $assigned[] = user_get_object($user_id)->getRealName();
+ }
+ $this->addHistory('assigned_to', join(', ', $assigned));
+ $arrChangedAndInNotice['assigned'] = ">";
+ $has_changes = true;
}
+
$old_array = array_keys($this->getDependentOn());
if (!is_array($depend_arr)) {
$depend_arr = array();
}
- $diff_array=array_diff($old_array,array_keys($depend_arr));
- if (count($diff_array)>0) {
- for ($tmp=0;$tmp<count($old_array);$tmp++) {
- $this->addHistory('dependent_on_id', $old_array[$tmp]);
- }
+ $removed=array_diff($old_array,array_keys($depend_arr));
+ $added=array_diff(array_keys($depend_arr), $old_array);
+ if (count($removed)>0 || count($added)>0) {
+ $this->addHistory('dependent_on', join(', ', $old_array));
$has_changes = true;
}
-
+
if (!$this->setDependentOn($depend_arr)) {
db_rollback();
return false;
$parent_id,
$group_project_id,
$this->getID())) ;
- if (!$res) {
- $this->setError('Error On ProjectTask::update-5: '.db_error().$sql);
+ if (!$res || db_affected_rows($res) < 1) {
+ $this->setError(db_error());
db_rollback();
return false;
} else {
if (!$this->fetchData($this->getID())) {
- $this->setError('Error On ProjectTask::update-6: '.db_error());
+ $this->setError(db_error());
db_rollback();
return false;
} else {
}
/**
- * sendNotice - contains the logic for sending email/jabber updates.
+ * sendNotice - contains the logic for sending email updates.
*
* @return boolean success.
*/
return true;
}
- $body = "Task #". $this->getID() ." has been updated. ".
- "\n\nProject: ". $this->ProjectGroup->Group->getPublicName();
- if (isset($arrChangedAndInNotice['subproject']))
- $body .= "\n". $arrChangedAndInNotice['subproject']."Subproject: ". $this->ProjectGroup->getName();
+ if (session_loggedin()) {
+ $user = session_get_user()->getRealName();
+ } else {
+ $user = '';
+ }
+
+ $body = "Task #". $this->getID() ." has been updated by $user.".
+ "\n\nProject: ". $this->ProjectGroup->Group->getPublicName();
- if (isset($arrChangedAndInNotice['summary']))
- $body .= "\n". $arrChangedAndInNotice['summary']. "Summary: ".util_unconvert_htmlspecialchars( $this->getSummary() );
+ if (isset($arrChangedAndInNotice['subproject']))
+ $body .= "\n". $arrChangedAndInNotice['subproject']."Subproject: ". $this->ProjectGroup->getName();
- if (isset($arrChangedAndInNotice['complete']))
- $body .= "\n". $arrChangedAndInNotice['complete']. "Complete: ". $this->getPercentComplete() ."%";
+ if (isset($arrChangedAndInNotice['summary']))
+ $body .= "\n". $arrChangedAndInNotice['summary']. "Summary: ".util_unconvert_htmlspecialchars( $this->getSummary() );
- if (isset($arrChangedAndInNotice['status']))
- $body .= "\n". $arrChangedAndInNotice['status']. "Status: ". $this->getStatusName();
+ if (isset($arrChangedAndInNotice['complete']))
+ $body .= "\n". $arrChangedAndInNotice['complete']. "Complete: ". $this->getPercentComplete() ."%";
+
+ if (isset($arrChangedAndInNotice['status']))
+ $body .= "\n". $arrChangedAndInNotice['status']. "Status: ". $this->getStatusName();
+
+ if (isset($arrChangedAndInNotice['assigned'])) {
+ $assigned = array();
+ foreach ($this->getAssignedTo() as $user_id) {
+ $assigned[] = user_get_object($user_id)->getRealName();
+ }
+ $body .= "\n". $arrChangedAndInNotice['assigned']. "Assigned: ". join(', ', $assigned);
+ }
- $body .= "\n\nDescription: ". util_unconvert_htmlspecialchars( $this->getDetails() );
+ $body .= "\n\nDescription: ". util_unconvert_htmlspecialchars( $this->getDetails() );
/*
Now get the followups to this task
<para>GNU/Linux Operating System</para>
</listitem>
<listitem>
- <para><ulink url="http://www.postgresql.org/">PostgreSQL</ulink> 8.3 or later (8.1, 8.2 should work)</para>
+ <para><ulink url="http://www.postgresql.org/">PostgreSQL</ulink> 8.3 or later</para>
</listitem>
<listitem>
<para><ulink url="http://www.apache.org/">Apache</ulink> 2.2 or later</para>
<listitem>
<para><ulink url="http://www.gnu.org/software/mailman/">GNU Mailman</ulink> and <ulink url="http://www.python.org/">Python</ulink> (Mailing list support)</para>
</listitem>
- <listitem>
- <para><ulink url="http://jabberd.jabberstudio.org/">Jabberd</ulink> (Jabber support)</para>
- </listitem>
<listitem>
<para><ulink url="http://www.aditus.nu/jpgraph/">JPGraph</ulink> (Gantt Charting and Graphing Support)</para>
</listitem>
svn IN A <replaceable>1.2.3.4</replaceable>
scm IN A <replaceable>1.2.3.4</replaceable>
ldap IN A <replaceable>1.2.3.4</replaceable>
- jabber IN A <replaceable>1.2.3.4</replaceable>
</screen>
<para>The new zone must be added in main BIND configuration file:</para>
<screen>
<section>
<title>Perl</title>
<para>If you want to use some of the Perl scripts that access the database, you'll need the <literal>DBI</literal> and <literal>DBD::Pg</literal> Perl modules. On Red Hat systems (and variants), you can get them by installing the <literal>libdbi</literal> and <literal>libdbd-pgsql</literal> packages. On Debian systems (and variants), the packages are called <literal>libdbi-perl</literal> and <literal>libdbd-pg-perl</literal>.</para>
- <para>You'll also need to install <filename>utils/include.pl</filename> to <filename class="directory">/usr/share/gforge/lib/</filename>, and put some configuration variables into <filename class="directory">/etc/gforge/local.pl</filename>. In particular, you'll need something like the following in <filename>local.pl</filename>:</para>
- <programlisting>
-$sys_default_domain = 'gforge.company.com' ;
-$sys_dbhost = '192.168.12.34' ;
-$sys_dbname = 'gforge' ;
-$sys_dbuser = 'gforge' ;
-$sys_dbpasswd = 'p455w0rd' ;
-</programlisting>
+ <para>You'll also need to install <filename>utils/include.pl</filename> to <filename class="directory">/usr/share/gforge/lib/</filename>.</para>
</section>
- <section>
- <title>Jabber Support</title>
- <para>FusionForge supports the sending of messages to jabber accounts. To accomplish this, you must have a user account setup on the jabber server that gforge can connect to and send messages.</para>
- <para>Once you have that user account, server, and password set up, just edit <filename>/etc/gforge/local.inc</filename> and add the information to the jabber section.</para>
- </section>
<section>
<title>Peer Ratings</title>
<para>Add yourself, and any others you wish, to the <quote>Peer Ratings</quote> project, which should be at <literal>/projects/peerrating/</literal> on the website. Make yourself an admininistrator of the project, and then proceed to <quote>rate</quote> other users on the website.</para>
;
; Documentation at:
; https://fusionforge.org/plugins/mediawiki/wiki/fusionforge/index.php/Configuration#Configuration_variables
+;
+; Note : instead of modifying this file, you may wish to place changed
+; settings in an overriding config.ini.d file, like the provided zzzz-local.ini
[core]
account_manager_type = pgsql
apache_group = "www-data"
apache_user = "www-data"
+compression_method = "gzip"
default_country_code = US
default_language = English
default_theme = gforge
news_group = 2
peer_rating_group = 4
project_registration_restricted = yes
+project_auto_approval = no
+project_auto_approval_user = admin
sendmail_path = "/usr/sbin/sendmail"
show_source = no
stats_group = 3
use_ftp = yes
use_ftp_uploads = no
use_gateways = yes
- use_jabber = no
use_mail = yes
use_manual_uploads = yes
use_news = yes
use_survey = yes
use_tracker = yes
use_trove = yes
+use_project_tags = yes
+use_project_full_list = yes
+allow_project_without_template = yes
use_webdav = no
+
+scm_single_host = yes
RequestHeader unset GForgeLdapPasswd
RequestHeader append GForgeLdapPasswd "{core/ldap_password}"
- RequestHeader unset GForgeJabberPasswd
- RequestHeader append GForgeJabberPasswd "{core/jabber_password}"
-
+
+RequestHeader unset GForgeSessionKey
+RequestHeader append GForgeSessionKey "{core/session_key}"
--- /dev/null
- $u->getJabberAddress(),
- $u->getJabberOnly(),
+<?php
+/** External authentication via LDAP for FusionForge
+ * Copyright 2003, Roland Mas <lolando@debian.org>
+ * Copyright 2004, Roland Mas <roland@gnurandal.com>
+ * The Gforge Group, LLC <http://gforgegroup.com/>
+ * Copyright 2004, Christian Bayle <bayle@debian.org>
+ * Copyright 2009-2010, Alain Peyrat, Alcatel-Lucent
+ * Copyright 2009, Chris Dalzell, OpenGameForge.org
+ * Copyright 2011, Roland Mas
+ *
+ * This file is part of FusionForge. FusionForge is free software;
+ * you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the Licence, or (at your option)
+ * any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+require_once $GLOBALS['gfcommon'].'include/User.class.php';
+
+class AuthLDAPPlugin extends ForgeAuthPlugin {
+ protected $saved_login;
+ protected $saved_password;
+ protected $saved_data;
+
+ function AuthLDAPPlugin() {
+ global $gfconfig;
+ $this->ForgeAuthPlugin();
+ $this->name = "authldap";
+ $this->text = "LDAP authentication";
+
+ $this->_addHook('display_auth_form');
+ $this->_addHook("check_auth_session");
+ $this->_addHook("fetch_authenticated_user");
+ $this->_addHook("sync_account_info");
+ $this->_addHook("close_auth_session");
+
+ $this->ldap_conn = false;
+ $this->saved_login = '';
+ $this->saved_password = '';
+ $this->saved_data = array();
+
+ $this->declareConfigVars();
+ }
+
+ function syncAccountInfo($params) {
+ if (!$this->syncDataOn($params['event'])) {
+ return true;
+ }
+ $n = $params['username'];
+ $data = $this->saved_data;
+
+ if (!$data) {
+ $data = $this->fetchDataForUser($n);
+ }
+
+ if (!$data) {
+ error_log("No data to sync from LDAP for username ".$n);
+ return true;
+ }
+
+ $u = user_get_object_by_name($n);
+
+ if (!$u) {
+ // No user by that name yet, let's create it
+
+ $u = new GFUser();
+
+ $user_data = array();
+
+ $user_data['unix_name'] = $n;
+ $user_data['firstname'] = '';
+ $user_data['lastname'] = '';
+ if ($this->saved_password == '') {
+ $user_data['password1'] = 'INVALID';
+ } else {
+ $user_data['password1'] = $this->saved_password;
+ }
+ $user_data['password2'] = $user_data['password1'];
+ $user_data['email'] = '';
+ $user_data['mail_site'] = 1;
+ $user_data['mail_va'] = 0;
+ $user_data['language_id'] = 1;
+ $user_data['timezone'] = 'GMT';
+ $user_data['jabber_address'] = '';
+ $user_data['jabber_only'] = 0;
+ $user_data['theme_id'] = 1;
+ $user_data['unix_box'] = '';
+ $user_data['address'] = '';
+ $user_data['address2'] = '';
+ $user_data['phone'] = '';
+ $user_data['fax'] = '';
+ $user_data['title'] = '';
+ $user_data['ccode'] = 'US';
+ $send_mail = false;
+
+ foreach (explode(',', forge_get_config('mapping', $this->name))
+ as $map_entry) {
+ list ($fffield, $ldapfield) = explode('=',$map_entry);
+ if (array_key_exists($ldapfield, $data)) {
+ $user_data[$fffield] = $data[$ldapfield][0];
+ }
+ }
+
+ if (!$u->create ($user_data['unix_name'],
+ $user_data['firstname'],
+ $user_data['lastname'],
+ $user_data['password1'],
+ $user_data['password2'],
+ $user_data['email'],
+ $user_data['mail_site'],
+ $user_data['mail_va'],
+ $user_data['language_id'],
+ $user_data['timezone'],
+ $user_data['jabber_address'],
+ $user_data['jabber_only'],
+ $user_data['theme_id'],
+ $user_data['unix_box'],
+ $user_data['address'],
+ $user_data['address2'],
+ $user_data['phone'],
+ $user_data['fax'],
+ $user_data['title'],
+ $user_data['ccode'],
+ $send_mail)) {
+ return false;
+ }
+
+ if (!$u->setStatus ('A')) {
+ return false;
+ }
+ }
+
+ if ($u->getStatus() == 'D') {
+ $u->setStatus('A');
+ }
+ if ($this->saved_password != ''
+ && !session_check_credentials_in_database($this->saved_login, $this->saved_password, false)) {
+ $u->setPasswd($this->saved_password);
+ }
+
+ $mapped_data = array(
+ 'username' => $u->getUnixName(),
+ 'md5_password' => '',
+ 'unix_password' => '',
+ 'firstname' => $u->getFirstName(),
+ 'lastname' => $u->getLastName(),
+ 'email' => $u->getEmail(),
+ 'phone' => $u->getPhone()
+ );
+
+ foreach (explode(',', forge_get_config('mapping', $this->name))
+ as $map_entry) {
+ list ($fffield, $ldapfield) = explode('=',$map_entry);
+ if (array_key_exists($ldapfield, $data)) {
+ $mapped_data[$fffield] = $data[$ldapfield][0];
+ }
+ }
+
+ $u->update($mapped_data['firstname'],
+ $mapped_data['lastname'],
+ $u->getLanguage(),
+ $u->getTimeZone(),
+ $u->getMailingsPrefs('site'),
+ $u->getMailingsPrefs('va'),
+ $u->usesRatings(),
++ '',
++ 0,
+ $u->getThemeID(),
+ $u->getAddress(),
+ $u->getAddress2(),
+ $mapped_data['phone'],
+ $u->getFax(),
+ $u->getTitle(),
+ $u->getCountryCode(),
+ $mapped_data['email']);
+
+ $u->setMD5Passwd ($mapped_data['md5_password']);
+ $u->setUnixPasswd ($mapped_data['unix_password']);
+ }
+
+ function displayAuthForm(&$params) {
+ if (!$this->isRequired() && !$this->isSufficient()) {
+ return true;
+ }
+ $return_to = $params['return_to'];
+ $loginname = '';
+
+ $result = '';
+
+ $result .= '<p>';
+ $result .= _('Cookies must be enabled past this point.');
+ $result .= '</p>';
+
+ $result .= '<form action="' . util_make_url('/plugins/authldap/post-login.php') . '" method="post">
+<input type="hidden" name="form_key" value="' . form_generate_key() . '"/>
+<input type="hidden" name="return_to" value="' . htmlspecialchars(stripslashes($return_to)) . '" />
+<p>';
+ $result .= _('LDAP Login name:');
+ $result .= '<br /><input type="text" name="form_loginname" value="' . htmlspecialchars(stripslashes($loginname)) . '" /></p><p>' . _('Password:') . '<br /><input type="password" name="form_pw" /></p><p><input type="submit" name="login" value="' . _('Login') . '" />
+</p>
+</form>';
+
+ $params['html_snippets'][$this->name] = $result;
+ }
+
+ protected function declareConfigVars() {
+ parent::declareConfigVars();
+
+ forge_define_config_item('start_tls', $this->name, 'no');
+ forge_set_config_item_bool('start_tls', $this->name);
+
+ forge_define_config_item('ldap_server', $this->name, 'ldap.example.com');
+ forge_define_config_item('ldap_port', $this->name, 389);
+ forge_define_config_item('base_dn', $this->name, 'ou=users,dc=example,dc=com');
+ forge_define_config_item('skipped_users', $this->name, '');
+ forge_define_config_item('manager_dn', $this->name, '');
+ forge_define_config_item('manager_password', $this->name, '');
+ }
+
+ /// HELPERS
+
+ function fetchDataForUser($loginname) {
+ if (!$this->ConnectLdap()) {
+ return false;
+ }
+
+ if (forge_get_config('manager_dn', $this->name)) {
+ ldap_bind($this->ldap_conn,
+ forge_get_config('manager_dn', $this->name),
+ forge_get_config('ldap_password'));
+ } else {
+ ldap_bind($this->ldap_conn);
+ }
+
+ $fieldname = 'uid';
+ foreach (explode(',', forge_get_config('mapping', $this->name))
+ as $map_entry) {
+ list ($fffield, $ldapfield) = explode('=',$map_entry);
+ if ($fffield == 'username') {
+ $fieldname = $ldapfield;
+ }
+ }
+
+ $res = ldap_search($this->ldap_conn, forge_get_config('base_dn', $this->name), "($fieldname=$loginname)");
+ if (!$res || ldap_count_entries($this->ldap_conn, $res) == 0) {
+ // No user by that name in LDAP directory
+ return false;
+ }
+ $info = ldap_get_entries($this->ldap_conn,$res);
+ $data = $info[0];
+ return $data;
+ }
+
+ function checkLDAPCredentials($loginname, $passwd) {
+ if (!$this->ConnectLdap()) {
+ // No connection to LDAP directory
+ if ($this->isRequired()) {
+ return FORGE_AUTH_AUTHORITATIVE_REJECT;
+ } else {
+ return FORGE_AUTH_NOT_AUTHORITATIVE;
+ }
+ }
+
+ $data = $this->fetchDataForUser($loginname);
+ if (!$data) {
+ return FORGE_AUTH_AUTHORITATIVE_REJECT;
+ }
+
+ if (@ldap_bind($this->ldap_conn, $data['dn'], $passwd)) {
+ // OK
+ $this->saved_data = $data;
+ $this->saved_password = $passwd;
+ return FORGE_AUTH_AUTHORITATIVE_ACCEPT;
+ } else {
+ // Probably invalid password
+ return FORGE_AUTH_AUTHORITATIVE_REJECT;
+ }
+ }
+
+ function ConnectLDAP() {
+ if ($this->ldap_conn) {
+ return true;
+ }
+
+ $server = forge_get_config('ldap_server', $this->name);
+ $port = forge_get_config('ldap_port', $this->name);
+ if ($port) {
+ $conn = ldap_connect($server, $port);
+ } else {
+ $conn = ldap_connect($server);
+ }
+
+ if (forge_get_config('ldap_version')) {
+ debuglog("LDAP: ldap_set_option ($this->ldap_conn, LDAP_OPT_PROTOCOL_VERSION, ".forge_get_config('ldap_version').");");
+ if (!ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, forge_get_config('ldap_version'))) {
+ debuglog("LDAP: ldap_set_option() failed: ".ldap_error($this->ldap_conn));
+ return false;
+ }
+ }
+
+ if (forge_get_config('start_tls', $this->name)) {
+ if (!ldap_start_tls($conn)) {
+ return false;
+ }
+ }
+
+ // If the ldap server does not allow anonymous bind,
+ // then authentificate with the server.
+ if (forge_get_config('manager_dn', $this->name)) {
+ if (!@ldap_bind($conn, forge_get_config('manager_dn', $this->name),
+ forge_get_config('ldap_password'))) {
+ error_log("LDAP application bind failed.");
+ return false;
+ }
+ }
+
+ $this->ldap_conn = $conn;
+ return true;
+ }
+}
+
+function debuglog($msg) {
+ $fp = fopen("/tmp/ldap.log", "a+");
+ fwrite ($fp, $msg."\n");
+ fclose($fp);
+}
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>
--- /dev/null
- $email,$mail_site,$mail_va,$language_id,$timezone,$jabber_address,$jabber_only,$theme_id,'',
+<?php
+
+/**
+ * User importing script for site admin
+ *
+ * Copyright (c) 2011 Olivier Berger & Institut Telecom
+ *
+ * This program was developped in the frame of the COCLICO project
+ * (http://www.coclico-project.org/) with financial support of the Paris
+ * Region council.
+ *
+ * This file is part of FusionForge. FusionForge is free software;
+ * you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the Licence, or (at your option)
+ * any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+// Import users from a JSON file (Site Admin tool)
+// Users are created in the pending queue, and await forge admin moderation
+
+// TODO : add confirmation pass instead of batch insertion
+
+require_once('../../../www/env.inc.php');
+require_once $gfwww.'include/pre.php';
+require_once $gfwww.'admin/admin_utils.php';
+
+require_once $gfplugins.'projectimport/common/ProjectImporter.class.php';
+require_once $gfplugins.'projectimport/common/UploadedFiles.class.php';
+
+include_once('arc/ARC2.php');
+
+/**
+ * Manages the display of the page : HTML + forms
+ *
+ * @author Olivier Berger
+ *
+ */
+class UsersImportPage extends FileManagerPage {
+
+ protected $importer;
+
+ protected $form_header_already_displayed;
+
+ function UsersImportPage($HTML) {
+ $this->form_header_already_displayed = false;
+
+ $this->importer = ProjectImporter::getInstance();
+
+ $storage = new SiteAdminFilesDirectory($HTML);
+
+ parent::FileManagerPage($HTML, $storage);
+ }
+
+ /**
+ * Display initial contents of the page
+ * @param string $message
+ */
+ function display_headers($message) {
+ global $feedback;
+
+ $params= array();
+ $params['title']=_('Users importer');
+ $params['toptab']='projectimport';
+
+ site_admin_header($params);
+
+ $this->message .= $message;
+ }
+
+ /**
+ * Display the page
+ */
+ function display_main() {
+
+ global $feedback;
+
+ // Do the work, first !
+ $html = $this->do_work();
+
+ if($this->message) {
+ echo $this->message . '<br />';
+ }
+ html_feedback_top($feedback);
+
+ echo $html;
+
+ // If invoked initially (not on callback) or if more details needed
+ // display the last part of the form for JSON file upload
+ if (! $this->form_header_already_displayed) {
+ echo '<form enctype="multipart/form-data" action="'.getStringFromServer('PHP_SELF').'" method="post">';
+ $this->form_header_already_displayed = True;
+ }
+
+ $preselected = False;
+
+ if (!$feedback) {
+ if ($this->posted_selecteddumpfile) {
+ $preselected = basename($this->posted_selecteddumpfile);
+ }
+ elseif ($this->posted_uploadedfile) {
+ $preselected = $this->posted_uploadedfile;
+ }
+ }
+
+ $selectiondialog = $this->storage->displayFileSelectionForm($preselected);
+
+ echo $selectiondialog;
+
+ // finally, display the file upload form
+ echo '<fieldset><legend>Please upload a file :</legend>
+ <p><center>
+ <input type="file" id="uploaded_file" name="uploaded_file" tabindex="2" size="30" />
+ </center></p>
+ </fieldset>
+ <div style="text-align:center;">
+ <input type="submit" name="submit" value="Submit" />
+ </div>
+ </form>';
+
+ site_footer(array());
+ }
+
+ /**
+ * Initializes data structures from POSTed data coming from the form input
+ */
+ function initialize_from_submitted_data() {
+ global $feedback;
+
+ $filechosen = $this->initialize_chosenfile_from_submitted();
+ if($filechosen) {
+ //print_r($filechosen);
+ $json = fread(fopen($this->posted_selecteddumpfile, 'r'),filesize($this->posted_selecteddumpfile));
+ if(! $json) {
+ $feedback = "Error : missing data";
+ }
+ else {
+
+ // print_r($imported_file);
+ $this->importer->parse_OSLCCoreRDFJSON($json);
+
+ $debug = FALSE;
+ if($debug) {
+ // Debug the loaded triples
+ $triples = $this->importer->parse_OSLCCoreRDFJSON($json);
+ $ser = ARC2::getTurtleSerializer();
+
+ if(count($triples)) {
+ $this->message .= '<pre>'. nl2br(htmlspecialchars($ser->toTurtle($triples))) . '</pre>';
+ }
+ }
+ }
+ }
+
+ if ((! $this->posted_selecteddumpfile) && (! $this->posted_uploadedfile)) {
+ $this->feedback(_('Please select an existing file to process, or upload a new one'));
+ }
+
+ }
+
+
+ /**
+ * Does the main work
+ * @return html string
+ */
+ function do_work() {
+ global $feedback;
+
+ $html = '';
+
+ // If the posted JSON file indeed contains a project dump, an importer was created,
+ // and if it has data we can work
+ // If it indeed has valid data
+ if ($this->importer->has_project_dump()) {
+
+ $this->message .= "Here are the results from your upload :";
+
+ // start HTML output
+ if (! $this->form_header_already_displayed) {
+ $this->form_header_already_displayed = true;
+ $html .= '<form enctype="multipart/form-data" action="'.getStringFromServer('PHP_SELF').'" method="post">';
+ }
+
+ $imported_users = $this->importer->get_user_objs();
+
+ if (count($imported_users)) {
+ $html .= $this->html_generator->boxTop(_("Users found in imported file"));
+
+ foreach($imported_users as $user => $user_obj) {
+
+ $unix_name = $user_obj->getUnixName();
+ $email = $user_obj->getEmail();
+
+ $firstname = $user_obj->getFirstname();
+ $lastname = $user_obj->getLastname();
+
+ $theme_id=$this->html_generator->getThemeIdFromName(forge_get_config('default_theme'));
+ $password1 = substr(md5($GLOBALS['session_ser'] . time() . util_randbytes()), 0, 8);
+ $password2 = $password1;
+ $language_id = language_name_to_lang_id (choose_language_from_context ());
+
+ $new_user = new GFUser();
+ $res = $new_user->create($unix_name,$firstname,$lastname,$password1,$password2,
++ $email,$mail_site,$mail_va,$language_id,$timezone,'',0,$theme_id,'',
+ $address,$address2,$phone,$fax,$title,$ccode,$send_mail);
+
+ if (!$res) {
+ $error_msg = $new_user->getErrorMessage();
+ if ($feedback) $feedback .= '<br />';
+ $feedback .= 'Import of "'. $unix_name . '": '. $error_msg;
+
+ $html .= _('Failed to create user'). ': <pre>'. $unix_name .'</pre>';
+ }
+ else {
+ $html .= _('Created user'). ': <pre>'. $unix_name .'</pre>';
+ }
+
+ $html .= 'User :<br />';
+ $html .= ' account name : '. $unix_name .'<br />';
+ $html .= ' email : '. $email .'<br />';
+ $html .= ' firstname : '. $firstname .'<br />';
+ $html .= ' lastname : '. $lastname .'<br />';
+ $html .= '<br/>';
+ }
+
+ $html .= $this->html_generator->boxBottom();
+
+ }
+
+ else {
+ $feedback .= 'Found no users<br />';
+ }
+ }
+ return $html;
+ }
+
+
+}
+
+// The user should be forge admin
+session_require_global_perm ('forge_admin');
+
+global $group_id, $feedback;
+
+$this_page = new UsersImportPage($HTML);
+
+//print_r($_POST);
+
+$message = '';
+
+// when called back by post form we can initialize some elements provided by the user
+if (getStringFromRequest('submit')) {
+
+ $this_page->initialize_from_submitted_data();
+
+}
+else {
+ $message .= "You can import a list of users from a JSON RDF document compatible with ForgePlucker's dump format.<br />";
+}
+
+$this_page->display_headers($message);
+
+$this_page->display_main();
+
+
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
* User account main page - show settings with means to change them
*
* Copyright 1999-2001 (c) VA Linux Systems
- * Copyright 2010 (c) Franck Villaume
- * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
+ * Copyright 2010-2011, Franck Villaume - Capgemini
+ * Copyright 2011, Alain Peyrat - Alcatel-Lucent
*
* This file is part of FusionForge. FusionForge is free software;
* you can redistribute it and/or modify it under the terms of the
require_once $gfcommon.'include/pre.php';
require_once $gfcommon.'include/timezones.php';
-$feedback = htmlspecialchars(getStringFromRequest('feedback'));
-$error_msg = htmlspecialchars(getStringFromRequest('error_msg'));
-
-session_require_login () ;
+session_require_login();
// get global users vars
-$u =& user_get_object(user_getid());
+$u = session_get_user();
if (!$u || !is_object($u)) {
- exit_error(_('Could Not Get User'));
+ exit_error(_('Could Not Get User'));
} elseif ($u->isError()) {
- exit_error($u->getErrorMessage(),'my');
+ exit_error($u->getErrorMessage(),'my');
}
if (getStringFromRequest('submit')) {
$phone = getStringFromRequest('phone');
$fax = getStringFromRequest('fax');
$title = getStringFromRequest('title');
- $jabber_address = getStringFromRequest('jabber_address');
- $jabber_only = getStringFromRequest('jabber_only');
$mail_site = getStringFromRequest('mail_site');
$mail_va = getStringFromRequest('mail_va');
$remember_user = getStringFromRequest('remember_user');
$use_ratings = getStringFromRequest('use_ratings');
+ $use_tooltips = (getStringFromRequest('use_tooltips')) ? getStringFromRequest('use_tooltips') : 0;
/*
//needs security audit
$refresh = ($language != $u->getLanguage() || $theme_id != $u->getThemeID());
if (!$u->update($firstname, $lastname, $language, $timezone, $mail_site, $mail_va, $use_ratings,
- $jabber_address,$jabber_only,$theme_id,$address,$address2,$phone,$fax,$title,$ccode,$use_tooltips)) {
- '',0,$theme_id,$address,$address2,$phone,$fax,$title,$ccode)) {
++ '',0,$theme_id,$address,$address2,$phone,$fax,$title,$ccode,$use_tooltips)) {
form_release_key(getStringFromRequest('form_key'));
$error_msg = $u->getErrorMessage();
$refresh_url = '/account/?error_msg='.urlencode($error_msg);
}
}
+$hookParams['user'] = user_get_object(user_getid());
+if (getStringFromRequest('submit')) {//if this is set, then the user has issued an Update
+ plugin_hook("userisactivecheckboxpost", $hookParams);
+}
+
$title = _('Account Maintenance');
site_user_header(array('title'=>$title));
<br />
<table width="100%" border="0">
-<tr valign="top">
+<tr class="top">
<td><?php echo _('Member since:'); ?> </td>
<td><strong><?php print date(_('Y-m-d H:i'),$u->getAddDate()); ?></strong></td>
</tr>
-<tr valign="top">
+<tr class="top">
<td><?php echo _('User Id:'); ?> </td>
<td><strong><?php print $u->getID(); ?></strong></td>
</tr>
-<tr valign="top">
+<tr class="top">
<td><?php echo _('Login name:'); ?> </td>
<td><strong><?php print $u->getUnixName(); ?></strong>
<br /><a href="change_pw.php">[<?php echo _('Change Password'); ?>]</a>
</td>
</tr>
- <?php
- if (forge_get_config('use_jabber')) {
- echo '<tr valign="top">
- <td>'. _('Jabber Address:') .'</td>
- <td>
- <input size="30" type="text" name="jabber_address" value="'. $u->getJabberAddress() .'" /><p />
- <input type="checkbox" name="jabber_only" value="1" '.(($u->getJabberOnly()) ? 'checked="CHECKED"' : '' ).' />
- '._('Send auto-generated notices only to my Jabber address').'.
- </td></tr>';
-
- }
- ?>
-
-
<tr>
<td colspan="2">
<?php
<div>
<input type="checkbox" name="use_ratings" value="1"<?php
if ($u->usesRatings()) print ' checked="checked"'; ?> />
- <?php printf(_('Participate in peer ratings. <i>(Allows you to rate other users using several criteria as well as to be rated by others. More information is available on your <a href="%s">user page</a> if you have chosen to participate in ratings.)</i>'),util_make_url_u ($u->getUnixName(),$u->getId()));
+ <?php printf(_('Participate in peer ratings. <i>(Allows you to rate other users using several criteria as well as to be rated by others. More information is available on your <a href="%s">user page</a> if you have chosen to participate in ratings.)</i>'),util_make_url_u ($u->getUnixName(),$u->getId()));
echo "\n</div>";
} ?>
+<div>
+<input type="checkbox" name="use_tooltips" value="1"<?php
+ if ($u->usesTooltips()) print ' checked="checked"'; ?> />
+ <?php echo _('Enable tooltips. Small help texts displayed on mouse over links, images.');
+?>
+</div>
+</td></tr>
-<table><tr><td><!-- hook[ --></td></tr>
<?php
-/* each hook emits a complete table row */
-$hookParams['user']= user_get_object(user_getid());
-if (getStringFromRequest('submit')) {//if this is set, then the user has issued an Update
- plugin_hook("userisactivecheckboxpost", $hookParams);
-} else {
- plugin_hook("userisactivecheckbox", $hookParams);
-}
-echo "\n\n</table><!-- ]hook -->\n";
+// displays a "Use xxxx Plugin" checkbox
+plugin_hook("userisactivecheckbox", $hookParams);
+?>
+<tr><td>
+<?php
echo $HTML->boxBottom();
// ############################### Shell Account
$language_id = getIntFromRequest('language_id');
$timezone = getStringFromRequest('timezone');
- $jabber_address = getStringFromRequest('jabber_address');
- $jabber_only = getStringFromRequest('jabber_only');
$theme_id = getIntFromRequest('theme_id');
$address = getStringFromRequest('address');
$address2 = getStringFromRequest('address2');
if (!form_key_is_valid(getStringFromRequest('form_key'))) {
exit_form_double_submit('my');
}
-
+
if (forge_get_config('user_registration_accept_conditions') && ! $accept_conditions) {
$warning_msg = _("You can't register an account unless you accept the terms of use.") ;
} else {
$send_mail = true;
$activate_immediately = false;
}
-
+
$new_user = new GFUser();
$register = $new_user->create($unix_name,$firstname,$lastname,$password1,$password2,
- $email,$mail_site,$mail_va,$language_id,$timezone,$jabber_address,$jabber_only,$theme_id,'',
+ $email,$mail_site,$mail_va,$language_id,$timezone,'',0,$theme_id,'',
$address,$address2,$phone,$fax,$title,$ccode,$send_mail);
if ($register) {
site_header(array('title'=>'Register Confirmation'));
}
if ($send_mail) {
echo '<p>';
- printf(_('You have registered the %1$s account on %2$s.'),
+ printf(_('You have registered the %1$s account on %2$s.'),
$new_user->getUnixName(),
forge_get_config ('forge_name'));
echo '</p>';
print '<p>' . _('A confirmation email is being sent to verify the submitted email address. Visiting the link sent in this email will activate the account.') . '</p>';
} else {
- print '<p>' ;
+ print '<p>' ;
printf (_('You have registered and activated user %1$s on %2$s. They will not receive an eMail about this fact.'), $unix_name, forge_get_config('forge_name'));
print '</p>' ;
}
} else {
echo _('Login Name (do not use uppercase letters):'); echo utils_requiredField();
} ?><br />
-<input type="text" name="unix_name" value="<?php print(htmlspecialchars($unix_name)); ?>" />
+<input type="text" required="required" name="unix_name" value="<?php print(htmlspecialchars($unix_name)); ?>" />
</p>
<p>
<?php echo _('Password (min. 6 chars):'); echo utils_requiredField(); ?><br />
-<input type="password" name="password1" />
+<input type="password" required="required" name="password1" />
</p>
<p>
<?php echo _('Password (repeat):'); echo utils_requiredField(); ?><br />
-<input type="password" name="password2" />
+<input type="password" required="required" name="password2" />
</p
><p>
<?php echo _('Title:'); ?><br />
</p>
<p>
<?php echo _('First Name:'); echo utils_requiredField(); ?><br />
-<input size="30" type="text" name="firstname" value="<?php print(htmlspecialchars($firstname)); ?>" />
+<input required="required" size="30" type="text" name="firstname" value="<?php print(htmlspecialchars($firstname)); ?>" />
</p>
<p>
<?php echo _('Last Name:'); echo utils_requiredField(); ?><br />
-<input size="30" type="text" name="lastname" value="<?php print(htmlspecialchars($lastname)); ?>" />
+<input required="required" size="30" type="text" name="lastname" value="<?php print(htmlspecialchars($lastname)); ?>" />
</p>
<p>
<?php echo _('Language Choice:'); ?><br />
<?php echo _('Timezone:'); ?><br />
<?php echo html_get_timezone_popup('timezone', $timezone); ?>
</p>
+<?php
+$toDisplay = html_get_theme_popup('theme_id', $theme_id);
+if($toDisplay != "") {
+?>
<p>
<?php echo _('Theme'); ?><br />
-<?php echo html_get_theme_popup('theme_id', $theme_id); ?>
+<?php echo $toDisplay; ?>
</p>
+<?php } ?>
<p>
<?php echo _('Country:'); ?><br />
<?php echo html_get_ccode_popup('ccode', $ccode); ?>
<br /><input size="30" type="text" name="email" value="<?php print(htmlspecialchars($email)); ?>" />
</p>
<p>
- <?php
- if (forge_get_config('use_jabber')) {
- echo _('Jabber Address:').'<br />
- <input size="30" type="text" name="jabber_address" value="'.
- htmlspecialchars($jabber_address) .'" /><br />
- <input type="checkbox" name="jabber_only" value="1" />
- '._('Send auto-generated notices only to my Jabber address').'.';
- }
- ?>
- </p>
- <p>
<?php echo _('Address:'); ?><br />
<input type="text" name="address" value="<?php echo htmlspecialchars($address); ?>" size="80" />
</p>
/**
* FusionForge Config File edit page
*
- * @version
- * @author
- * @copyright
+ * @version
+ * @author
+ * @copyright
* Copyright 2005 GForge, LLC
* http://fusionforge.org/
*
require_once $gfcommon.'include/pre.php';
require_once $gfwww.'admin/admin_utils.php';
- 'jabber_host' => 'use_jabber',
- 'jabber_port' => 'use_jabber',
- 'jabber_password' => 'use_jabber',
- 'jabber_user' => 'use_jabber',
+$config_depends_on = array(
+ 'ftp_upload_dir' => 'use_ftp',
+ 'https_port' => 'use_ssl',
+ 'images_secure_url' => 'use_ssl',
+ 'project_auto_approval_user' => 'project_auto_approval',
+ 'shell_host' => 'use_shell',
+);
+
+class configCheck {
+ static function account_manager_type($v) { return ($v === 'pgsql'); }
+ static function chroot($v) { return is_dir($v); }
+ static function config_path($v) { return is_dir($v); }
+ static function data_path($v) { return is_dir($v); }
+ static function default_theme($v) { return db_numrows(db_query_params('SELECT * FROM themes WHERE dirname=$1', array($v))) === 1; }
+ static function extra_config_dirs($v) { return is_dir($v); }
+ static function ftp_upload_dir($v) { return is_dir($v); }
+ static function gitweb_cmd($v) { return is_file($v); }
+ static function groupdir_prefix($v) { return is_dir($v); }
+ static function homedir_prefix($v) { return is_dir($v); }
+ static function installation_environment($v) { return in_array($v, array('production', 'integration', 'development')); }
+ static function jpgraph_path($v) { return is_dir($v); }
+ static function log_path($v) { return is_dir($v); }
+ static function mailman_path($v) { return is_dir($v); }
+ static function plugins_path($v) { return is_dir($v); }
+ static function project_auto_approval_user($v) { return db_numrows(db_query_params('SELECT * FROM users WHERE user_name=$1', array($v))) === 1; }
+ static function repos_path($v) { return is_dir($v); }
+ static function scm_snapshots_path($v) { return is_dir($v); }
+ static function scm_tarballs_path($v) { return is_dir($v); }
+ static function sendmail_path($v) { return is_file($v); }
+ static function session_key($v) { return ($v !== 'foobar'); }
+ static function source_path($v) { return is_dir($v); }
+ static function news_group($v) { return db_numrows(db_query_params('SELECT * FROM groups WHERE group_id=$1', array($v))) === 1; }
+ static function stats_group($v) { return db_numrows(db_query_params('SELECT * FROM groups WHERE group_id=$1', array($v))) === 1; }
+ static function template_group($v) { return db_numrows(db_query_params('SELECT * FROM groups WHERE group_id=$1', array($v))) === 1; }
+ static function peer_rating_group($v) { return db_numrows(db_query_params('SELECT * FROM groups WHERE group_id=$1', array($v))) === 1; }
+ static function themes_root($v) { return is_dir($v); }
+ static function upload_dir($v) { return is_dir($v); }
+ static function url_root($v) { return is_dir($v); }
+}
+
site_admin_header(array('title'=>_('Configuration Manager')));
echo "<h2>".sprintf (_('Configuration from the config API (*.ini files)'))."</h2>" ;
$variables = $c->get_variables ($section) ;
natsort($variables) ;
foreach ($variables as $var) {
+ if (isset($config_depends_on[$var]) &&
+ (!$c->get_value($section, $config_depends_on[$var]))) {
+ continue;
+ }
+ $v = $c->get_value ($section, $var) ;
+
+ if (method_exists('configCheck', $var)) {
+ $class = configCheck::$var($v)? 'class="good_value"': 'class="wrong_value"';
+ } else {
+ $class = '';
+ }
echo '<tr '. $HTML->boxGetAltRowStyle($counter++) .'><td>'.$var ;
if ($c->is_bool ($section, $var)) {
print " (boolean)" ;
}
print "</td><td>" ;
print htmlspecialchars($c->get_raw_value ($section, $var)) ;
- print "</td><td>" ;
- $v = $c->get_value ($section, $var) ;
+ print "</td><td $class>" ;
if ($c->is_bool ($section, $var)) {
if ($v) {
print "true" ;
} else {
print htmlspecialchars($v);
}
- print "</td></tr>" ;
+ print "</td></tr>\n" ;
}
}
* Copyright 1999-2001 (c) VA Linux Systems
* Copyright 2010, FusionForge Team
* Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
+ * Copyright 2012, Franck Villaume - TrivialDev
* Copyright © 2012
* Thorsten Glaser <t.glaser@tarent.de>
*
* Assumes $user object for displayed user is present
*/
+
+require_once $gfwww.'include/user_profile.php';
+
require_once $gfwww.'include/vote_function.php';
$title = _('User Profile');
$HTML->header(array('title'=>$title));
-echo $HTML->boxTop(_('Personal Information'), _('Personal Information')); ?>
-
-<div about="" typeof="sioc:UserAccount">
+echo $HTML->boxTop(_('Personal Information'), _('Personal Information'));
-<table width="100%" cellpadding="2" cellspacing="2" border="0">
-<tr>
- <td width="150"><?php plugin_hook("user_logo", array('user_id' => $user_id, 'size' => 'l')); ?></td>
- <td>
-
-<table class="my-layout-table" id="user-profile-personal-info">
-<tr>
- <td>
- <?php echo _('User Id:') ?>
- </td>
- <td>
- <strong>
-<?php
-//print '<div property ="foaf:member" content="fusionforge:ForgeCommunity">';
-//echo '</div>';
-// description as a FusionForge Community member
-//print '<div property ="dc:Identifier" content="'.$user_id.'">';
-
- if (session_loggedin() && user_ismember(1)) {
- echo util_make_link ('/admin/useredit.php?user_id='.$user_id,$user_id);
- } else {
- echo $user_id;
-//echo '</div>';
- }
?>
- </strong><?php if(forge_get_config('use_people')) { ?>( <?php echo util_make_link ('/people/viewprofile.php?user_id='.$user_id,'<strong>'._('Skills Profile').'</strong>'); ?> )<?php } ?>
- </td>
-</tr>
-
-<tr>
- <td><?php echo _('Login name:') ?></td>
- <td><strong><span property="sioc:name"><?php
- print $user->getUnixName();
- ?></span></strong></td>
-</tr>
-
-<tr>
- <td><?php echo _('Real Name:') ?> </td>
- <td>
- <div rev="foaf:account">
- <div about="#me" typeof="foaf:Person">
- <strong><span property="foaf:name"><?php
- $user_title = $user->getTitle();
- print ($user_title ? $user_title .' ' :''). $user->getRealName();
- ?></span></strong>
- </div>
- </div>
- </td>
-</tr>
-
-<?php if(!isset($GLOBALS['sys_show_contact_info']) || $GLOBALS['sys_show_contact_info']) { ?>
-<tr>
- <td><?php echo _('Email Address:') ?>: </td>
- <td>
- <strong><?php
- $user_mail=$user->getEmail();
- $user_mailsha1=$user->getSha1Email();
- // Removed for privacy reasons
- //print '<span property="sioc:email" content="'. $user_mail .'">';
- print '<span property="sioc:email_sha1" content="'. $user_mailsha1 .'">';
- echo util_make_link ('/sendmessage.php?touser='.$user_id, str_replace('@',' @nospam@ ',$user_mail));
- echo '</span>';
- ?></strong>
- </td>
-</tr>
-
-<?php if ($user->getAddress() || $user->getAddress2()) { ?>
-<tr>
- <td><?php echo _('Address:'); ?></td>
- <td><?php echo $user->getAddress().'<br/>'.$user->getAddress2(); ?></td>
-</tr>
-<?php } ?>
-
-<?php if ($user->getPhone()) { ?>
-<tr>
- <td><?php echo _('Phone:'); ?></td>
- <td><?php
-//print '<div property="foaf:phone" content="'.$user->getPhone().'">';
-echo $user->getPhone();
-//echo '</div>';
-?></td>
-</tr>
-<?php } ?>
-
-<?php if ($user->getFax()) { ?>
-<tr>
- <td><?php echo _('FAX:'); ?></td>
- <td><?php echo $user->getFax(); ?></td>
-</tr>
-<?php } ?>
-<?php } ?>
-
-<tr>
- <td>
- <?php echo _('Site Member Since:') ?>
- </td>
- <td><strong><?php print date(_('Y-m-d H:i'), $user->getAddDate()); ?></strong>
- </td>
-</tr>
-</table>
-</td>
-</tr>
-</table>
+
+<div about="" typeof="sioc:UserAccount">
-
<?php
+
+ echo user_personal_information($user);
+
if (forge_get_config('use_ratings')) {
echo $HTML->boxMiddle(_('Peer Rating'), _('Peer Rating'));
echo '<table class="my-layout-table" id="user-profile-rating">';
Get their diary information
*/
- $res = db_query_params ('SELECT count(*) from user_diary WHERE user_id=$1 AND is_public=1',
- array ($user_id));
- echo _('Diary/Note entries:').' '.db_result($res,0,0).'
+ $res = db_query_params('SELECT count(*) from user_diary WHERE user_id=$1 AND is_public=1',
+ array($user_id));
+ echo _('Diary/Note entries:').' '.db_result($res, 0, 0).'
<p>';
//.'<span rel="foaf:weblog">'
- echo util_make_link ('/developer/diary.php?diary_user='.$user_id,htmlentities(_('View Diary & Notes')));
+ echo util_make_link('/developer/diary.php?diary_user='.$user_id,htmlentities(_('View Diary & Notes')));
//.'</span>'.
echo '</p>
<p>';
- echo util_make_link ('/developer/monitor.php?diary_user='.$user_id,
+ echo util_make_link('/developer/monitor.php?diary_user='.$user_id,
html_image("ic/check.png",'15','13',array(),0) ._('Monitor this Diary')
) ;
echo '</p>';
$hookparams['user_id'] = $user_id;
- plugin_hook("user_personal_links",$hookparams);
+ plugin_hook("user_personal_links", $hookparams);
}
?>
// sioc:UserGroups for all members of a project are named after /projects/A_PROJECT/members/
$usergroup_uri = $project_uri .'members/';
-
print '<div rel="sioc:member_of">'."\n"
.'<div about="'. $usergroup_uri .'" typeof="sioc:UserGroup">'."\n"
.'<div rel="sioc:usergroup_of">'."\n"
$sioc_has_function_close = "";
foreach ($roles as $r) {
if ($r instanceof RoleExplicit
- && $r->getHomeProject() != NULL
- && $r->getHomeProject()->getID() == $p->getID()) {
+ && $r->getHomeProject() != NULL
+ && $r->getHomeProject()->getID() == $p->getID()) {
$role_names[] = $r->getName() ;
print '<div property="sioc:has_function" content= "'.$r->getName().'">';
$sioc_has_function_close .= "</div>";
--- /dev/null
- if ($user->getJabberAddress()) {
- $html .= '
- <tr>
- <td>'. _('Jabber Address') .'</td>
- <td>
- <a href="jabber:'. $user->getJabberAddress() .'"><strong>'. $user->getJabberAddress() .'</strong></a>
- </td>
- </tr>';
- }
-
+<?php
+/**
+ * Developer Profile Info
+ *
+ * Copyright 1999-2001 (c) VA Linux Systems
+ * Copyright 2010, FusionForge Team
+ * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
+ * http://fusionforge.org
+ *
+ * This file is part of FusionForge. FusionForge is free software;
+ * you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the Licence, or (at your option)
+ * any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+// This code was extracted from user_home.php and factorized in a function
+
+/**
+* Display user's profile / personal info either in compact or extensive way
+*
+* @param object $user
+* @param boolean $compact
+* @return string HTML
+*/
+function user_personal_information($user, $compact = false, $title = false) {
+
+ $user_id = $user->getID();
+
+ $user_logo = false;
+ $params = array('user_id' => $user_id, 'size' => 'l', 'content' => '');
+ plugin_hook_by_reference('user_logo', $params);
+ if ($params['content']) {
+ $user_logo = $params['content'];
+ }
+
+ if($compact) {
+ $html = '<table>';
+ if($title) {
+ $html .= '<tr>
+ <td colspan="2">'. $title . '</td>
+ </tr>';
+ }
+ } else {
+ $html = '<table width="100%" cellpadding="2" cellspacing="2" border="0">';
+ }
+
+ $html .= '<tr>';
+ if($user_logo) {
+ $html .= '<td width="150">'. $user_logo .'</td>';
+ }
+ else {
+ $html .= '<td></td>';
+ }
+ $html .='<td>
+
+ <table class="my-layout-table" id="user-profile-personal-info">
+ <tr>
+ <td>'. _('User Id:') . '</td>';
+
+ //print '<div property ="foaf:member" content="fusionforge:ForgeCommunity">';
+ //echo '</div>';
+ // description as a FusionForge Community member
+ //print '<div property ="dc:Identifier" content="'.$user_id.'">';
+ $user_id_html = '';
+ if (session_loggedin() && forge_check_global_perm('forge_admin')) {
+ $user_id_html = util_make_link('/admin/useredit.php?user_id='.$user_id, $user_id);
+ } else {
+ $user_id_html = $user_id;
+ //echo '</div>';
+ }
+ $html .= '<td><strong>'. $user_id_html .'</strong>';
+ if(!$compact && forge_get_config('use_people')) {
+ $html .= '(' . util_make_link ('/people/viewprofile.php?user_id='.$user_id,'<strong>'._('Skills Profile').'</strong>') . ')';
+ }
+ $html .= '</td>
+ </tr>
+ <tr>
+ <td>'. _('Login name:') .'</td>
+ <td><strong><span property="sioc:name">' .
+ $user->getUnixName() . '</span></strong></td>
+ </tr>
+ <tr>
+ <td>'. _('Real Name:') .'</td>';
+ $user_title = $user->getTitle();
+ $user_title_name = $user_title ? $user_title .' ' :'' . $user->getRealName();
+ $html .= '<td>
+ <div rev="foaf:account">
+ <div about="#me" typeof="foaf:Person">
+ <strong><span property="foaf:name">'.
+ $user_title_name .'</span></strong>
+ </div>
+ </div>
+ </td>
+ </tr>';
+ if (!$compact) {
+ if(!isset($GLOBALS['sys_show_contact_info']) || $GLOBALS['sys_show_contact_info']) {
+
+ $user_mail=$user->getEmail();
+ $user_mailsha1=$user->getSha1Email();
+
+ $html .= '<tr>
+ <td>'. _('Email Address:') .': </td>
+ <td><strong>'.
+
+ // Removed for privacy reasons
+ //print '<span property="sioc:email" content="'. $user_mail .'">';
+ '<span property="sioc:email_sha1" content="'. $user_mailsha1 .'">' .
+ util_make_link ('/sendmessage.php?touser='.$user_id, str_replace('@',' @nospam@ ',$user_mail)) .
+ '</span>
+ </strong>
+ </td>
+ </tr>';
+
+ if ($user->getAddress() || $user->getAddress2()) {
+ $html .= '<tr>
+ <td><'. _('Address:') .'</td>
+ <td>'. $user->getAddress() .'<br/>'. $user->getAddress2() .'</td>
+ </tr>';
+ }
+
+ if ($user->getPhone()) {
+ $html .= '<tr>
+ <td>' . _('Phone:') . '</td>
+ <td>' .
+ //print '<div property="foaf:phone" content="'.$user->getPhone().'">';
+ $user->getPhone()
+ //echo '</div>';
+ .'</td>
+ </tr>';
+ }
+
+ if ($user->getFax()) {
+ $html .= '<tr>
+ <td>'. _('FAX:') .'</td>
+ <td>'. $user->getFax() .'</td>
+ </tr>';
+ }
+ }
+ }
+ $html .= '
+ <tr>
+ <td>'. _('Site Member Since:') .'</td>
+ <td><strong>'. relative_date($user->getAddDate()). '</strong>
+ </td>
+ </tr>';
+ if($compact) {
+ $user_uri = util_make_url ("/users/". $user->getUnixName() . "/");
+ $html .= '<tr>
+ <td><small>'. _('URI:') .'</small></td>
+ <td><small><a href="'. $user_uri .'">'. $user_uri .'</a></small></td>
+ </tr>';
+ }
+ $html .= '</table>
+ </td>
+ </tr>
+ </table>';
+
+ return $html;
+}
+
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
+?>
'status' => array('name'=>'status', 'type' => 'xsd:string'),
'timezone' => array('name'=>'timezone', 'type' => 'xsd:string'),
'country_code' => array('name'=>'country_code', 'type' => 'xsd:string'),
- 'add_date' => array('name'=>'add_date', 'type' => 'xsd:int'),
- 'language_id' => array('name'=>'language_id', 'type' => 'xsd:int')
+ 'add_date' => array('name'=>'add_date', 'type' => 'xsd:int'),
+ 'language_id' => array('name'=>'language_id', 'type' => 'xsd:int')
) );
// Array of users
$uri.'#getUsersByName','rpc','encoded'
);
- //mail_site,mail_va,language_id,timezone,jabber_address,jabber_only,
+//addUser (unix_name,firstname,lastname,password1,password2,email,
- //updateUser (session_ser,user_id,firstname,lastname,language_id,timezone,mail_site,mail_va,use_ratings,jabber_address,$jabber_only,theme_id,address,address2,phone,fax,title,ccode)
++ //mail_site,mail_va,language_id,timezone,dummy1,dummy2,
+ //theme_id,unix_box='shell',address='',address2='',phone='',fax='',
+ //title='',ccode='US',send_mail)
+$server->register(
+ 'addUser',
+ array('unix_name'=>'xsd:string','firstname'=>'xsd:string',
+ 'lastname'=>'xsd:string','password1'=>'xsd:string',
+ 'password2'=>'xsd:string','email'=>'xsd:string',
+ 'mail_site'=>'xsd:string','mail_va'=>'xsd:string',
+ 'language_id'=>'xsd:int','timezone'=>'xsd:string',
+ 'jabber_address'=>'xsd:string','jabber_only'=>'xsd:int',
+ 'theme_id'=>'xsd:int','unix_box'=>'xsd:string',
+ 'address'=>'xsd:string','address2'=>'xsd:string',
+ 'phone'=>'xsd:string','fax'=>'xsd:string',
+ 'title'=>'xsd:string','ccode'=>'xsd:string'),
+ array('addUserResonse'=>'xsd:int'),
+ $uri,
+ $uri.'#addUser','rpc','encoded'
+);
+
++//updateUser (session_ser,user_id,firstname,lastname,language_id,timezone,mail_site,mail_va,use_ratings,dummy1,dummy2,theme_id,address,address2,phone,fax,title,ccode)
+$server->register(
+ 'updateUser',
+ array('session_ser'=>'xsd:string',
+ 'user_id'=>'xsd:string',
+ 'firstname'=>'xsd:string',
+ 'lastname'=>'xsd:string',
+ 'language_id'=>'xsd:int',
+ 'timezone'=>'xsd:string',
+ 'mail_site'=>'xsd:string',
+ 'mail_va'=>'xsd:string',
+ 'use_ratings'=>'xsd:string',
+ 'jabber_address'=>'xsd:string',
+ 'jabber_only'=>'xsd:int',
+ 'theme_id'=>'xsd:int',
+ 'address'=>'xsd:string',
+ 'address2'=>'xsd:string',
+ 'phone'=>'xsd:string',
+ 'fax'=>'xsd:string',
+ 'title'=>'xsd:string',
+ 'ccode'=>'xsd:string'),
+ array('updateUserResonse'=>'xsd:int'),
+ $uri,
+ $uri.'#updateUser','rpc','encoded'
+);
+
+//deleteUser (session_ser,user_id)
+$server->register(
+ 'deleteUser',
+ array('session_ser'=>'xsd:string','user_id'=>'xsd:string'),
+ array('deleteUserResonse'=>'xsd:boolean'),
+ $uri,
+ $uri.'#deleteUser','rpc','encoded'
+);
+
+//changeStatus (session_ser,user_id,status)
+$server->register(
+ 'changeStatus',
+ array('session_ser'=>'xsd:string',
+ 'user_id'=>'xsd:string',
+ 'status'=>'xsd:string'),
+ array('changeStatusResonse'=>'xsd:boolean'),
+ $uri,
+ $uri.'#changeStatus','rpc','encoded'
+);
+
+//changePassword (session_ser,user_id,password)
+$server->register(
+ 'changePassword',
+ array('session_ser'=>'xsd:string',
+ 'user_id'=>'xsd:string',
+ 'password'=>'xsd:string'),
+ array('changePasswordResonse'=>'xsd:boolean'),
+ $uri,
+ $uri.'#changePassword','rpc','encoded'
+);
+
//getGroups (id array)
$server->register(
'userGetGroups',
return users_to_soap($usrs);
}
+//add user object
+function addUser($unix_name,$firstname,$lastname,$password1,$password2,$email,
+ $mail_site,$mail_va,$language_id,$timezone,$jabber_address,$jabber_only,$theme_id,$unix_box,$address,$address2,$phone,$fax,$title,$ccode){
+ $new_user = new GFUser();
+
+ $register = $new_user->create($unix_name,$firstname,$lastname,$password1,$password2,$email,$mail_site,$mail_va,$language_id,$timezone,$jabber_address,$jabber_only,$theme_id,'',$address,$address2,$phone,$fax,$title,$ccode);
+
+ if (!$register){
+ return new soap_fault ('3004','user','Could Not Add A New User','Could Not Add A New User');
+ }
+
+ return $new_user->getID();
+}
+
+//update user object
+function updateUser ($session_ser,$user_id,$firstname,$lastname,$language_id,$timezone,$mail_site,$mail_va,$use_ratings,$jabber_address,$jabber_only,$theme_id,$address,$address2,$phone,$fax,$title,$ccode){
+ continue_session($session_ser);
+ $user =& user_get_object($user_id);
+ if (!$user || !is_object($user)) {
+ return new soap_fault ('updateUser','Could Not Get User','Could Not Get User');
+ }
+
+ if (!$user->update($firstname,$lastname,$language_id,$timezone,$mail_site,$mail_va,$use_ratings,$jabber_address,$jabber_only,$theme_id,$address,$address2,$phone,$fax,$title,$ccode)){
+ return new soap_fault ('updateUser',$user->getErrorMessage(),$user->getErrorMessage());
+ }else{
+ return $user->getID();
+ }
+}
+
+//delete user object
+function deleteUser ($session_ser,$user_id){
+ continue_session($session_ser);
+ $user =& user_get_object($user_id);
+ if (!$user || !is_object($user)) {
+ return new soap_fault ('deleteUser','Could Not Get User','Could Not Get User');
+ }elseif ($user->isError()){
+ return new soap_fault ('deleteUser',$user->getErrorMessage(),$user->getErrorMessage());
+ }
+
+ if (!$user->delete(true)){
+ return new soap_fault ('deleteUser',$user->getErrorMessage(),$user->getErrorMessage());
+ }else{
+ return true;
+ }
+}
+
+//change status user object
+function changeStatus ($session_ser,$user_id,$status){
+ continue_session($session_ser);
+ $user =& user_get_object($user_id);
+ if (!$user || !is_object($user)) {
+ return new soap_fault ('changeStatus','Could Not Get User','Could Not Get User');
+ }elseif ($user->isError()){
+ return new soap_fault ('changeStatus',$user->getErrorMessage(),$user->getErrorMessage());
+ }
+
+ if (!$user->setStatus($status)){
+ return new soap_fault ('changeStatus',$user->getErrorMessage(),$user->getErrorMessage());
+ }else{
+ return true;
+ }
+}
+
+//change password user object
+function changePassword ($session_ser,$user_id,$password){
+ continue_session($session_ser);
+ $user =& user_get_object($user_id);
+ if (!$user || !is_object($user)) {
+ return new soap_fault ('changePassword','Could Not Get User','Could Not Get User');
+ }elseif ($user->isError()){
+ return new soap_fault ('changePassword',$user->getErrorMessage(),$user->getErrorMessage());
+ }
+
+ if (!$user->setPasswd($password)){
+ return new soap_fault ('changePassword',$user->getErrorMessage(),$user->getErrorMessage());
+ }else{
+ return true;
+ }
+}
+
//get groups for user_id
function &userGetGroups($session_ser,$user_id) {
continue_session($session_ser);
} else {
//build an array of just the fields we want
$return[] = array(
- 'user_id'=>$usrs[$i]->data_array['user_id'],
+ 'user_id'=>$usrs[$i]->data_array['user_id'],
'user_name'=>$usrs[$i]->data_array['user_name'],
'title'=>$usrs[$i]->data_array['title'],
'firstname'=>$usrs[$i]->data_array['firstname'],
'fax'=>$usrs[$i]->data_array['fax'],
'status'=>$usrs[$i]->data_array['status'],
'timezone'=>$usrs[$i]->data_array['timezone'],
- 'country_code'=>$usrs[$i]->data_array['country_code'],
+ 'country_code'=>$usrs[$i]->data_array['ccode'],
'add_date'=>$usrs[$i]->data_array['add_date'],
- 'language_id'=>$usrs[$i]->data_array['language_id']
+ 'language_id'=>$usrs[$i]->data_array['language']
);
}