* $db stores a database resource
*/
var $db;
-
+
/**
* store the database name used to instantiate the connection
*/
public $db_name;
-
+
/**
* Constucts a new DataAccess object
* @param $host string hostname for dbserver
throw new DataAccessException('Unable to access the database. Please contact your administrator.');
}
}
-
+
protected function connect($host, $user, $pass, $opt) {
return mysql_connect($host, $user, $pass, true, $opt);
}
-
+
var $store;
-
+
/**
* Fetches a query resources and stores it in a local member
* @param $sql string the database query to run
return mysql_error();
}
}
-
+
/**
* Quote variable to make safe
* @see http://php.net/mysql-real-escape-string
}
$str.=$this->quoteSmart($piece,$params);
$after_first=true;
- }
+ }
return $str;
}
-
+
function escapeInt($v, $null = CODENDI_DB_NOT_NULL) {
$m = array();
function mysql_query_params($sql,$params=array(),$database) {
if(!empty($params)) {
for ($i=1;$i<=count($params);$i++ ) {
- $args[]="$".$i;
+ $args[]="$".$i;
}
return mysql_query(str_replace($args,$params,$sql),$database);
} else {
return mysql_query($sql,$database);
}
-
+
}
return true;
}
}
-
+
/**
* Prepare ranking of items.
- *
+ *
* @see https://partners.xrce.xerox.com/plugins/docman/?group_id=120&action=show&id=95
- *
+ *
* @param int $id The id of the item to rank. 0 if the item doesn't exist.
* @param int $parent_id The id of the element used to group items
* @param mixed $rank The rank asked for the items. Possible values are :
* 'end' => to put item after each others
* 'up' => to put item before previous sibling
* 'down' => to put item after next sibling
- * <int> => to put item at a specific position.
+ * <int> => to put item at a specific position.
* Please note that for a new item ($id = 0) you must not use
* '--', 'up' or 'down' value
* @param string $primary_key the column name of the primary key. Default 'id'
*/
function prepareRanking($id, $parent_id, $rank, $primary_key = 'id', $parent_key = 'parent_id', $rank_key = 'rank') {
$newRank = null;
-
+
// First, check if there is already some items
$sql = sprintf('SELECT NULL'.
' FROM '. $this->table_name .
return util_get_image_theme($url);
}
?>
-
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License,
* 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
// MailingList backend class
/* This is only sample
require_once $gfplugins.'soapadmin/include/BackendHelloworld.class.php' ;
-
+
$res = db_query_params ('SELECT id,type, parameters FROM system_event WHERE status=$1 ORDER BY id DESC',
- array ('1'));
+ array ('1'));
if (!$res) {
printf('Unable to get list of events: '.db_error());
return false;
}
if(isset($events)) {
foreach($events as $event_id => $log) {
- $sql = "UPDATE system_event SET end_date=$1, log=$2, status='3' WHERE id=$3;";
+ $sql = "UPDATE system_event SET end_date=$1, log=$2, status='3' WHERE id=$3;";
$result = db_query_params($sql,array(time(),$log,$event_id));
if (!$result) {
printf('Unable to update the list of events: '.db_error());
-<?php
+<?php
// here you can put all your configuration variables
if ($G_SESSION->usesPlugin("soapadmin")) {
$param = '?type=user&id=' . $G_SESSION->getId() . "&pluginname=" . $this->name; // we indicate the part we're calling is the user one
echo ' | ' . $HTML->PrintSubMenu (array ($text),
- array ('/plugins/soapadmin/index.php' . $param ));
+ array ('/plugins/soapadmin/index.php' . $param ));
}
} elseif ($hookname == "groupmenu") {
$group_id=$params['group'];
} else {
$params['TITLES'][]=$this->text." is [Off]";
$params['DIRS'][]='';
- }
+ }
(($params['toptab'] == $this->name) ? $params['selected']=(count($params['TITLES'])-1) : '' );
} elseif ($hookname == "groupisactivecheckbox") {
//Check if the group is active
echo '<p>'.util_make_link ("/plugins/soapadmin/admin/index.php?id=".$group->getID().'&type=admin&pluginname='.$this->name,
_('SoapAdmin Admin')).'</p>' ;
}
- }
+ }
elseif ($hookname == "blahblahblah") {
// ...
- }
+ }
}
}
require_once $gfconfig.'plugins/soapadmin/config.php';
// the header that displays for the user portion of the plugin
-function soapadmin_Project_Header($params) {
+function soapadmin_Project_Header($params) {
global $DOCUMENT_ROOT,$HTML,$id;
- $params['toptab']='soapadmin';
+ $params['toptab']='soapadmin';
$params['group']=$id;
- /*
- Show horizontal links
- */
- site_project_header($params);
+ /*
+ Show horizontal links
+ */
+ site_project_header($params);
}
// the header that displays for the project portion of the plugin
function soapadmin_User_Header($params) {
global $DOCUMENT_ROOT,$HTML,$user_id;
- $params['toptab']='soapadmin';
+ $params['toptab']='soapadmin';
$params['user']=$user_id;
- /*
- Show horizontal links
- */
- site_user_header($params);
+ /*
+ Show horizontal links
+ */
+ site_user_header($params);
}
$type = getStringFromRequest('type');
$id = getStringFromRequest('id');
$pluginname = getStringFromRequest('pluginname');
-
+
if (!$type) {
exit_error("Cannot Process your request","No TYPE specified"); // you can create items in Base.tab and customize this messages
} elseif (!$id) {
exit_error("Invalid Project", "Inexistent Project");
}
if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the SoapAdmin plugin active
- exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
+ exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
}
$userperm = $group->getPermission($user);//we'll check if the user belongs to the group (optional)
if ( !$userperm->IsMember()) {
exit_error("Access Denied", "You are not a member of this project");
}
// other perms checks here...
- soapadmin_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
+ soapadmin_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
// DO THE STUFF FOR THE PROJECT PART HERE
echo "We are in the Project SoapAdmin plugin <br>";
echo "Greetings from planet " . $world; // $world comes from the config file in /etc
} elseif ($type == 'user') {
- $realuser = user_get_object($id);//
+ $realuser = user_get_object($id);//
if (!($realuser) || !($realuser->usesPlugin($pluginname))) {
exit_error("Error", "First activate the User's $pluginname plugin through Account Manteinance Page");
}
if ( (!$user) || ($user->getID() != $id)) { // if someone else tried to access the private SoapAdmin part of this user
exit_error("Access Denied", "You cannot access other user's personal $pluginname");
}
- soapadmin_User_Header(array('title'=>'My '.$pluginname,'pagename'=>"$pluginname",'sectionvals'=>array($realuser->getUnixName())));
+ soapadmin_User_Header(array('title'=>'My '.$pluginname,'pagename'=>"$pluginname",'sectionvals'=>array($realuser->getUnixName())));
// DO THE STUFF FOR THE USER PART HERE
echo "We are in the User SoapAdmin plugin <br>";
echo "Greetings from planet " . $world; // $world comes from the config file in /etc
exit_error("Invalid Project", "Inexistent Project");
}
if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the SoapAdmin plugin active
- exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
+ exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
}
$userperm = $group->getPermission($user);//we'll check if the user belongs to the group
if ( !$userperm->IsMember()) {
}
//only project admin can access here
if ( $userperm->isAdmin() ) {
- soapadmin_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
+ soapadmin_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
// DO THE STUFF FOR THE PROJECT ADMINISTRATION PART HERE
echo "We are in the Project SoapAdmin plugin <font color=\"#ff0000\">ADMINISTRATION</font> <br>";
echo "Greetings from planet " . $world; // $world comes from the config file in /etc
exit_error("Access Denied", "You are not a project Admin");
}
}
- }
-
+ }
+
site_project_footer(array());
// Local Variables:
*-
* FusionForge Core Api (full description in FusionforgeCoreApi.wsdl)
* Rewrite of the older Api based on NuSOAP
- *
+ *
* Main technical features :
* - Based on the PHP SOAP extension (PHP > 5.x)
* - SOAP Document/Litteral wrapped mode
* - WS-I Basic Profile Compliant
- *
+ *
*/
require_once './coreapiservice.php';
# uncomment this for development purpose only
-# ini_set('soap.wsdl_cache_enabled', '0');
+# ini_set('soap.wsdl_cache_enabled', '0');
use_soap_error_handler(false);
$server->setClass("CoreApiService");
$server->handle();
-?>
\ No newline at end of file
+?>
-<?php
+<?php
/**
* getSCMData_soap
*/
*/
public $user;
}
-?>
\ No newline at end of file
+?>
*/
Class CoreApiServer extends SoapServer {
- private $logger;
-
+ private $logger;
+
/**
* Default class map for wsdl=>php
* @access private
* @param array $options Options for the SoapClient
*/
public function __construct($wsdl="FusionforgeCoreApi.wsdl", $options=array()) {
-
+
$this->logger = Logger::getLogger('api.soap.core.CoreApi');
$this->logger->debug("FusionForgeCoreApi Soap Server created ...");
foreach(self::$classmap as $wsdlClassName => $phpClassName) {
class CoreApiService {
- private $logger;
-
+ private $logger;
+
public function __construct() {
// log4php logger initialization for the class
$this->logger = Logger::getLogger('fusionforge.api.soap.CoreApi');
}
-
+
/**
* Checks if an argument list matches against a valid argument type list
* @param array $arguments The argument list to check
}
return true;
}
-
+
/**
* Service Call: getVersion
- *
+ *
* @param mixed getVersion_soap (Soap request object)
* @return getVersionResponse_soap (Soap response object) or SoapFault if parameter are invalid
*/
// Invalid parameters => return a soap fault
return new SoapFault($e->getCode(),$e->getMessage());
}
-
+
$fusionforge = new FusionForge();
$response = new getVersionResponse_soap();
$response->version = $fusionforge->software_version;
/**
* Service Call: getGroups
- *
+ *
* @param mixed getGroups_soap (Soap request object)
* @return getGroupsResponse_soap (Soap response object) or SoapFault if parameters are invalid
*/
$validParameters = array(
"(getGroups_soap)",
);
-
+
try {
$args = func_get_args();
$this->_checkArguments($args, $validParameters);
// Invalid parameters => return a soap fault
return new SoapFault($e->getCode(),$e->getMessage());
}
-
+
$grps =& group_get_objects($group_ids);
if (!$grps) {
$this->logger->debug("Could Not Get Groups by Id");
$response = new getGroupsResponse_soap();
$this->logger->debug((count($grps)+1)." Groups objects found");
-
+
for ($i=0; $i<count($grps); $i++) {
$group = new group_soap();
$group->group_id = $grps[$i]->data_array['group_id'];
$response->group[$i]=$group;
$this->logger->debug("Adding Group objects : ".var_export($group, true));
}
-
+
return $response;
}
/**
* Service Call: getUsers
- *
+ *
* @param mixed getUsers_soap (Soap request object)
* @return getUsersResponse_soap (Soap response object) or SoapFault if parameters are invalid
*/
else {
$user_id = array(0=>$mixed->user_id);
}
-
+
$validParameters = array(
"(getUsers_soap)",
);
-
+
try {
$args = func_get_args();
$this->_checkArguments($args, $validParameters);
// Invalid parameters => return a soap fault
return new SoapFault($e->getCode(),$e->getMessage());
}
-
+
$users =& user_get_objects($user_id);
$this->logger->debug("users found : ".var_export($users, true));
if (!$users) {
return new SoapFault('3001','Could Not Get Users By Id');
- }
-
+ }
+
$response = new getUsersResponse_soap();
for ($i=0; $i<count($users); $i++) {
if ($users[$i]->isError()){
$user->language_id=$users[$i]->data_array['language_id'];
$response->user[$i]=$user;
}
- }
+ }
return $response;
}
/**
* Service Call: getGroupsByName
- *
+ *
* @param mixed getGroupsByName_soap (Soap request object)
* @return getGroupsByNameResponse_soap (Soap response object) or SoapFault if parameters are invalid
*/
else {
$group_names = array(0=>$mixed->group_name);
}
-
+
$validParameters = array(
"(getGroupsByName_soap)",
);
-
+
try {
$args = func_get_args();
$this->_checkArguments($args, $validParameters);
catch (Exception $e) {
// Invalid parameters => return a soap fault
return new SoapFault($e->getCode(),$e->getMessage());
- }
+ }
$grps =& group_get_objects_by_name($group_names);
if (!$grps) {
return new SoapFault('2002','Could Not Get Groups by Name');
}
-
+
$response = new getGroupsByNameResponse_soap();
// $grps contains an array of Group object
for ($i=0; $i<count($grps); $i++) {
/**
* Service Call: getPublicProjectNames
- *
+ *
* @param mixed getPublicProjectNames_soap (Soap request object)
* @return getPublicProjectNamesResponse_soap (Soap response object) or SoapFault if parameters are invalid
*/
catch (Exception $e) {
// Invalid parameters => return a soap fault
return new SoapFault($e->getCode(),$e->getMessage());
- }
- // SOAP Response
+ }
+ // SOAP Response
$response = new getPublicProjectNamesResponse_soap();
$forge = new FusionForge();
$response->project_name = $forge->getPublicProjectNames();
/**
* Service Call: getUsersByName
- *
+ *
* @param mixed getUsersByName_soap (Soap request object)
* @return getUsersByNameResponse_soap (Soap response object) or SoapFault if parameters are invalid
*/
else {
$user_names = array(0=>$mixed->user_name);
}
-
+
$validParameters = array(
"(getUsersByName_soap)",
);
catch (Exception $e) {
// Invalid parameters => return a soap fault
return new SoapFault($e->getCode(),$e->getMessage());
- }
-
+ }
+
$users =& user_get_objects_by_name($user_names);
if (!$users) {
return new SoapFault('3002','Could Not Get Users By Name');
- }
-
+ }
+
$response = new getUsersByNameResponse_soap();
for ($i=0; $i<count($users); $i++) {
if ($users[$i]->isError()){
$user->language_id=$users[$i]->data_array['language_id'];
$response->user[$i]=$user;
}
- }
+ }
return $response;
}
/**
* Service Call: userGetGroups
- *
+ *
* @param mixed userGetGroups_soap (Soap request object)
* @return userGetGroupsResponse_soap (Soap response object) or SoapFault if parameters are invalid
*/
public function userGetGroups($mixed = null) {
-
+
$this->logger->debug("CoreApiService Soap call : userGetGroups for user_id ".var_export($mixed, true));
$user_id = $mixed->user_id;
-
+
$validParameters = array(
"(userGetGroups_soap)",
);
catch (Exception $e) {
// Invalid parameters => return a soap fault
return new SoapFault($e->getCode(),$e->getMessage());
- }
-
+ }
+
$user =& user_get_object($user_id);
if (!$user) {
return new SoapFault('3003','Could Not Get Users Groups');
$grps = $user->getGroups();
$this->logger->debug(count($grps). " groups found");
$response = new userGetGroupsResponse_soap();
-
+
for ($i=0; $i<count($grps); $i++) {
if ($grps[$i]->isError()) {
//skip it if it had an error
$this->logger->debug("adding group : ".var_export($group, true));
}
}
-
+
$this->logger->debug("userGetGroupsResponse_soap : ".var_export($response, true));
-
+
return $response;
}
/**
* Service Call: getSCMData
- *
+ *
* @param mixed getSCMData_soap (Soap request object)
* @return getSCMDataResponse_soap (Soap response object) or SoapFault if parameters are invalid
*/
catch (Exception $e) {
// Invalid parameters => return a soap fault
return new SoapFault($e->getCode(),$e->getMessage());
- }
+ }
// Search the group object in the database
$grp =& group_get_object($group_id);
$this->logger->debug("group_get_object : ".var_export($grp, true));
$this->logger->error('SCM is not enabled in this project ; group_id : '.$group_id);
// TODO : Error code to be determined
return new SoapFault ('-1','SCM is not enabled in this project');
- }
-
+ }
+
// Create the SOAP response
$response = new getSCMDataResponse_soap();
$scm_data = new scmData_soap();
-
+
if ($grp->usesPlugin("scmcvs")) {
$scm_data->type = "CVS";
$scm_data->allow_anonymous = $grp->enableAnonSCM();
$scm_data->box = $grp->getSCMBox();
$scm_data->root = $GLOBALS["svn_root"]."/".$grp->getUnixName();
$scm_data->module = ""; // doesn't apply to SVN
-
+
// Note: This is an ugly hack. We can't access SVN plugin object for this project
// directly. Currently this is being rewritten, but for now we must make this.
-
+
//TODO How to have access to $gfconfig variable ??
-
+
include $gfconfig.'plugins/scmsvn/config.php';
$scm_data->connection_string = "http".(($use_ssl) ? "s" : "")."://".$grp->getSCMBox()."/".$svn_root."/".$grp->getUnixName();
}
-
+
$response->scm_data= $scm_data;
return $response;
}
-
+
}
?>
require_once $gfconfig.'plugins/soapadmin/config.php';
// the header that displays for the user portion of the plugin
-function soapadmin_Project_Header($params) {
+function soapadmin_Project_Header($params) {
global $DOCUMENT_ROOT,$HTML,$id;
- $params['toptab']='soapadmin';
+ $params['toptab']='soapadmin';
$params['group']=$id;
- /*
- Show horizontal links
- */
- site_project_header($params);
+ /*
+ Show horizontal links
+ */
+ site_project_header($params);
}
// the header that displays for the project portion of the plugin
function soapadmin_User_Header($params) {
global $DOCUMENT_ROOT,$HTML,$user_id;
- $params['toptab']='soapadmin';
+ $params['toptab']='soapadmin';
$params['user']=$user_id;
- /*
- Show horizontal links
- */
- site_user_header($params);
+ /*
+ Show horizontal links
+ */
+ site_user_header($params);
}
$type = getStringFromRequest('type');
$id = getStringFromRequest('id');
$pluginname = getStringFromRequest('pluginname');
-
+
if (!$type) {
exit_error("Cannot Process your request","No TYPE specified"); // you can create items in Base.tab and customize this messages
} elseif (!$id) {
exit_error("Invalid Project", "Inexistent Project");
}
if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the SoapAdmin plugin active
- exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
+ exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
}
$userperm = $group->getPermission($user);//we'll check if the user belongs to the group (optional)
if ( !$userperm->IsMember()) {
exit_error("Access Denied", "You are not a member of this project");
}
// other perms checks here...
- soapadmin_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
+ soapadmin_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
// DO THE STUFF FOR THE PROJECT PART HERE
echo "We are in the Project SoapAdmin plugin <br>";
echo "Greetings from planet " . $world; // $world comes from the config file in /etc
} elseif ($type == 'user') {
- $realuser = user_get_object($id);//
+ $realuser = user_get_object($id);//
if (!($realuser) || !($realuser->usesPlugin($pluginname))) {
exit_error("Error", "First activate the User's $pluginname plugin through Account Manteinance Page");
}
if ( (!$user) || ($user->getID() != $id)) { // if someone else tried to access the private SoapAdmin part of this user
exit_error("Access Denied", "You cannot access other user's personal $pluginname");
}
- soapadmin_User_Header(array('title'=>'My '.$pluginname,'pagename'=>"$pluginname",'sectionvals'=>array($realuser->getUnixName())));
+ soapadmin_User_Header(array('title'=>'My '.$pluginname,'pagename'=>"$pluginname",'sectionvals'=>array($realuser->getUnixName())));
// DO THE STUFF FOR THE USER PART HERE
echo "We are in the User SoapAdmin plugin <br>";
echo "Greetings from planet " . $world; // $world comes from the config file in /etc
exit_error("Invalid Project", "Inexistent Project");
}
if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the SoapAdmin plugin active
- exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
+ exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
}
$userperm = $group->getPermission($user);//we'll check if the user belongs to the group
if ( !$userperm->IsMember()) {
}
//only project admin can access here
if ( $userperm->isAdmin() ) {
- soapadmin_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
+ soapadmin_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
// DO THE STUFF FOR THE PROJECT ADMINISTRATION PART HERE
echo "We are in the Project SoapAdmin plugin <font color=\"#ff0000\">ADMINISTRATION</font> <br>";
echo "Greetings from planet " . $world; // $world comes from the config file in /etc
exit_error("Access Denied", "You are not a project Admin");
}
}
- }
-
+ }
+
site_project_footer(array());
// Local Variables:
if ($G_SESSION->usesPlugin("webcalendar")) {
$param = '?type=user&id=' . $G_SESSION->getId() . "&pluginname=" . $this->name; // we indicate the part we're calling is the user one
echo ' | ' . $HTML->PrintSubMenu (array ($text),
- array (util_make_url('/plugins/webcalendar/index.php' . $param)));
+ array (util_make_url('/plugins/webcalendar/index.php' . $param)));
}
} elseif ($hookname == "groupmenu") {
$group_id=$params['group'];
} else {
$params['TITLES'][]=$this->text." is [Off]";
$params['DIRS'][]='';
- }
+ }
(($params['toptab'] == $this->name) ? $params['selected']=(count($params['TITLES'])-1) : '' );
} elseif ($hookname == "groupisactivecheckbox") {
///Check if the group is active
// this displays the link in the project admin options page to it's webcalendar administration
$group_id = $params['group_id'];
$group = &group_get_object($group_id);
-
+
if ( $group->usesPlugin ( $this->name ) ) {
echo util_make_link('/plugins/webcalendar/index.php?id=' . $group->getID() . '&type=admin&pluginname=' . $this->name,_('View the webcalendar Administration')) . '<br />';
}
-
- }
+
+ }
elseif ($hookname == "call_user_cal") {
//my/index.php line 365
?>
-
+
<div id="cal" class="tabbertab" title="WebCalendar" >
<table width="100%" cellspacing="0" cellpadding="0" border="0" ><tr align="center" ><td >
<iframe name="webcal" src="<?php echo util_make_url('/plugins/webcalendar/login.php?type=user'); ?>" border=no scrolling="yes" width="100%" height="700"></iframe>
<script>
function reload_webcal() {
frames['webcal'].location.replace('<?php echo util_make_url("/plugins/webcalendar/login.php?type=user"); ?>');
-
+
}
</script>
- <?php
+ <?php
}
elseif ($hookname == "call_user_js") {
// my/index.php line 67
-
+
?>
onclick="reload_webcal()"
- <?php
+ <?php
} elseif ($hookname == "role_get") {
$role =& $params['role'] ;
$new_pa =& $params['new_pa'] ;
if (USE_PFO_RBAC) {
- $projects = $role->getLinkedProjects() ;
+ $projects = $role->getLinkedProjects() ;
foreach ($projects as $p) {
$role->normalizePermsForSection ($new_pa, 'plugin_webcalendar_access', $p->getID()) ;
}
}
}
}
- elseif ($hookname == "user_setstatus") {
+ elseif ($hookname == "user_setstatus") {
$user = $params['user'] ;
$status = $params['status'] ;
-
+
if ($status == 'A') {
$res_cal = db_query_params ('SELECT COUNT(*) FROM webcal_user WHERE cal_login=$1',
array ($user->getUnixName())) ;
}
} else {
db_query_params ('DELETE FROM webcal_user WHERE cal_login = $1',
- array ($user->getUnixName()));
+ array ($user->getUnixName()));
db_query_params ('DELETE FROM webcal_asst WHERE cal_boss = $1 OR cal_assistant = $2',
array ($user->getUnixName(),
$user->getUnixName())) ;
}
} elseif ($hookname == "group_approved") {
$project = group_get_object ($params['group_id']) ;
-
+
$emails = array () ;
foreach ($project->getAdmins() as $u) {
$emails[] = $u->getEmail() ;
}
-
+
db_query_params ('INSERT INTO webcal_user (cal_login, cal_passwd, cal_firstname,cal_email) VALUES ($1,$2,$3,$4)',
array ($project->getUnixName(),
'cccc',
array ($params[0],
$params[1]));
$row_flags = db_fetch_array($res);
-
-
-
+
+
+
//get user name
$res_nom_boss = db_query_params ('SELECT unix_group_name FROM groups WHERE group_id = $1 ',
array ($params[1]));
$row_nom_boss = db_fetch_array($res_nom_boss);
-
-
+
+
$res_nom_user = db_query_params ('SELECT user_name,email FROM users WHERE user_id = $1 ',
array ($params[0]));
$row_nom_user = db_fetch_array($res_nom_user);
-
+
//verif du flag sur webcal
$res = db_query_params ('SELECT COUNT(*) FROM webcal_asst WHERE cal_boss = $1 AND cal_assistant = $2',
array ($row_nom_boss['unix_group_name'],
$row_nom_user['user_name']));
$row_num = db_fetch_array($res);
-
+
//select email
$res_mail = db_query_params ('SELECT cal_email FROM webcal_user WHERE cal_login = $1',
array ($row_nom_boss['unix_group_name']));
$row_mail = db_fetch_array($res_mail);
- $mail = $row_mail['cal_email'];
-
+ $mail = $row_mail['cal_email'];
+
if(($row_num[0] != 1 ) && (trim($row_flags['admin_flags']) == 'A')){
//recuperer le nom du user et du group
$res_insert = db_query_params ('INSERT INTO webcal_asst (cal_boss, cal_assistant) VALUES ($1,$2)',
array ($row_nom_boss['unix_group_name'],
$row_nom_user['user_name']));
-
+
//we add email of the new admin
$mail = str_replace($row_nom_user['email'],"",$mail);
$mail = str_replace(",".$row_nom_user['email'],"",$mail);
-
+
if($mail == ""){
- $virgule = "";
+ $virgule = "";
}
else {
- $virgule = ",";
+ $virgule = ",";
}
-
+
$mail = $mail.$virgule.$row_nom_user['email'] ;
-
+
//$mail = $row_mail['cal_email'].",".$row_nom_user['email'] ;
db_query_params ('UPDATE webcal_user SET cal_email = $1 WHERE cal_login = $2',
array (trim($mail,','),
elseif($row_num[0] == 1 && (trim($row_flags['admin_flags']) != 'A')){
$res_del = db_query_params ('DELETE FROM webcal_asst WHERE cal_boss = $1 AND cal_assistant = $2',
array ($row_nom_boss['unix_group_name'],
- $row_nom_user['user_name']));
-
+ $row_nom_user['user_name']));
+
//we del email of the old admin
$mail = str_replace(",".$row_nom_user['email'],"",$row_mail['cal_email']) ;
db_query_params ('UPDATE webcal_user SET cal_email = $1 WHERE cal_login = $2',
array ($mail,
$row_nom_boss['unix_group_name']));
}
-
+
}
elseif ($hookname == "change_cal_permission") {
//argument user_id -> $params[0]et project_id -> $params[1]
$project = group_get_object ($project_id) ;
$user = user_get_object ($user_id) ;
-
+
if (USE_PFO_RBAC) {
if (forge_check_perm_for_user ($user, 'plugin_webcalendar_access', $project_id, 'write')) {
$user_perm = 1 ;
$row_flags = db_fetch_array($res);
$user_perm = $row_flags['value'] ;
}
-
+
//flag verification
$res = db_query_params ('SELECT COUNT(*) FROM webcal_asst WHERE cal_boss = $1 AND cal_assistant = $2',
array ($project->getUnixName(),
$user->getUnixName()));
$row_num = db_fetch_array($res);
-
+
//select email
$res_mail = db_query_params ('SELECT cal_email FROM webcal_user WHERE cal_login = $1',
array ($project->getUnixName()));
$row_mail = db_fetch_array($res_mail);
$mail = $row_mail['cal_email'] ;
-
+
//if group admin
if($project_id == 1){
$res_flags_admin = db_query_params ('SELECT admin_flags FROM user_group WHERE user_id = $1 AND group_id = $2',
}
if(($row_num[0] != 1 ) && ($user_perm == 1)){
-
+
$res_insert = db_query_params ('INSERT INTO webcal_asst (cal_boss, cal_assistant) VALUES ($1,$2)',
array ($project->getUnixName(),
$user->getUnixName()));
-
+
//we add email of the new admin
$mail = str_replace($user->getEmail(),"",$mail);
$mail = str_replace(",".$user->getEmail(),"",$mail);
-
+
if($mail == ""){
- $virgule = "";
+ $virgule = "";
}
else {
- $virgule = ",";
+ $virgule = ",";
}
-
+
$mail = $mail.$virgule.$user->getEmail() ;
-
-
-
+
+
+
//$mail = $row_mail['cal_email'].",".$row_nom_user['email'] ;
db_query_params ('UPDATE webcal_user SET cal_email = $1 WHERE cal_login = $2',
array (trim($mail,','),
elseif($row_num[0] == 1 && ($user_perm != 1)){
$res_del = db_query_params ('DELETE FROM webcal_asst WHERE cal_boss = $1 AND cal_assistant = $2',
array ($project->getUnixName(),
- &nb