Пример #1
0
 public function delete()
 {
     $params = $this->input->post('params');
     if (!is_array($params) || count($params) == 0) {
         $this->returnError('Some information are missing');
     }
     //TODO translate with CI standard way
     extract($params);
     //
     //     	if(isset($params['procedure'])) $procedure = urlencode(trim($params['procedure']));
     //     	if(isset($params['object_name'])) $object_name = urlencode(trim($params['object_name']));
     //     	if(isset($params['object_id'])) $object_id = urlencode(trim($params['object_id']));
     switch ($procedure) {
         case 'deleteLocation':
             if (!isset($object_name) || !isset($object_id)) {
                 $this->returnError('Some information are missing');
             }
             if (strtolower($object_name) != 'location') {
                 $this->returnError('The specified ' . $object_name . ' can not be deleted.');
             }
             $location = new Mdl_Location();
             $location->locId = $object_id;
             $input = array();
             $input['locId'] = $object_id;
             if ($location->delete($input)) {
                 $to_js = array();
                 $to_js['message'] = 'The location has been deleted.';
                 $to_js['focus_tab'] = '#tab_locations';
             } else {
                 $this->returnError('The location has not been deleted');
             }
             break;
         case 'deleteOrganizationMembership':
             if (!isset($object_name) || !isset($object_id) || !isset($related_object_name) || !isset($related_object_id)) {
                 $this->returnError('Some information are missing');
             }
             if (strtolower($object_name) != 'organization') {
                 $this->returnError('The specified object_name ' . $object_name . ' can not be used in this procedure.');
             }
             //get the person
             $person = new Mdl_Person();
             $person->uid = $related_object_id;
             $result = $person->get(null);
             if ($result['status']['status_code'] == '200' && $result['status']['results_number'] == '1') {
                 //get the organization
                 $organization = new Mdl_Organization();
                 $organization->oid = $object_id;
                 $res = $organization->get();
                 if ($res['status']['status_code'] == '200' && $result['status']['results_number'] == '1') {
                     $organization->arrayToObject($res['data']['0']);
                     $organization_name = $organization->o;
                 } else {
                     $this->returnError('The selected organization can not be found');
                 }
                 //update person's attributes
                 $person->arrayToObject($result['data']['0']);
                 $ordn = explode(',', $person->oRDN);
                 foreach ($ordn as $key => $item) {
                     if ($item == $object_id) {
                         unset($ordn[$key]);
                     }
                 }
                 if (count($ordn) > 0) {
                     $person->oRDN = implode(',', $ordn);
                 } else {
                     $person->oRDN = '';
                 }
                 $oAdminRDN = explode(',', $person->oAdminRDN);
                 foreach ($oAdminRDN as $key => $item) {
                     if ($item == $object_id) {
                         unset($oAdminRDN[$key]);
                     }
                 }
                 if (count($oAdminRDN) > 0) {
                     $person->oAdminRDN = implode(',', $oAdminRDN);
                 } else {
                     $person->oAdminRDN = '';
                 }
                 $o = explode(',', $person->o);
                 foreach ($o as $key => $item) {
                     if ($item == $organization_name) {
                         unset($o[$key]);
                     }
                 }
                 if (count($o) > 0) {
                     $person->o = implode(',', $o);
                 } else {
                     $person->o = '';
                 }
                 if ($person->save(false)) {
                     $to_js = array();
                     $to_js['message'] = $person->cn . " has been disassociated from " . $organization_name;
                     $to_js['focus_tab'] = '#tab_memberOf';
                 } else {
                     $this->returnError('The association process failed.');
                 }
             }
             break;
         default:
             $this->returnError('An invalid procedure has been requested');
             break;
     }
     if (isset($to_js)) {
         $this->output($to_js);
     } else {
         $this->returnError('Something went wrong');
     }
 }
Пример #2
0
 /**
  * This controller method (function) is defined as calledback in the config.php and is called by MCB when the System Settings Panel is displayed.
  * MCB provides, so, a specific "settings tab" for the module Contact. This function is called only once, when the System Settings is loaded.
  * After that, during the accordion operations etc, this function is no more called. 
  * The aim of the function is to get, populate and return the html of several tpl files. The html returned will populate the "setting tab" 
  * 
  * @access		public
  * @param		array | null	An array containing the data to send to the tpl files or nothing
  * @return		string | false
  * @example
  * @see
  * 
  * @author 		Damiano Venturin
  * @copyright 	2V S.r.l.
  * @license		GPL
  * @link		http://www.squadrainformatica.com/en/development#mcbsb  MCB-SB official page
  * @since		Feb 6, 2012
  * 
  */
 public function display_settings()
 {
     $data = array();
     $obj = new Mdl_Person();
     $obj->getProperties();
     $obj->prepareShow();
     $data['settings_person'] = $this->display_object_settings($obj);
     $obj = new Mdl_Organization();
     $obj->getProperties();
     $obj->prepareShow();
     $data['settings_organization'] = $this->display_object_settings($obj);
     $obj = new Mdl_Location();
     $obj->getProperties();
     $obj->prepareShow();
     $data['settings_location'] = $this->display_object_settings($obj);
     $this->plenty_parser->parse('settings.tpl', $data, false, 'smarty', 'contact');
 }