/**
  * Check right on an contract - overloaded to check max_links_allowed
  *
  * @param $ID ID of the item (-1 if new item)
  * @param $right Right to check : r / w / recursive
  * @param $input array of input data (used for adding item)
  *
  * @return boolean
  **/
 function can($ID, $right, &$input = NULL)
 {
     if ($ID < 0) {
         // Ajout
         $contract = new Contract();
         if (!$contract->getFromDB($input['contracts_id'])) {
             return false;
         }
         if ($contract->fields['max_links_allowed'] > 0 && countElementsInTable($this->getTable(), "`contracts_id`='" . $input['contracts_id'] . "'") >= $contract->fields['max_links_allowed']) {
             return false;
         }
     }
     return parent::can($ID, $right, $input);
 }
Ejemplo n.º 2
0
 /**
  * Check right on an item - overloaded to check is_global
  *
  * @param $ID     ID of the item (-1 if new item)
  * @param $right  Right to check : r / w / recursive
  * @param $input  array of input data (used for adding item) (default NULL)
  *
  * @return boolean
  **/
 function can($ID, $right, array &$input = NULL)
 {
     if ($ID < 0) {
         // Ajout
         if (!($item = new $input['itemtype']())) {
             return false;
         }
         if (!$item->getFromDB($input['items_id'])) {
             return false;
         }
         if ($item->getField('is_global') == 0 && self::countForItem($ID) > 0) {
             return false;
         }
     }
     return parent::can($ID, $right, $input);
 }
 /**
  * Check right on an item - overloaded to check is_global
  *
  * @param $ID ID of the item (-1 if new item)
  * @param $right Right to check : r / w / recursive
  * @param $input array of input data (used for adding item)
  *
  * @return boolean
  **/
 function can($ID, $right, &$input = NULL)
 {
     if ($ID < 0) {
         // Ajout
         if (!class_exists($input['itemtype'])) {
             return false;
         }
         $item = new $input['itemtype']();
         if (!$item->getFromDB($input['items_id'])) {
             return false;
         }
         if ($item->getField('is_global') == 0 && $this->countForItem($item) > 0) {
             return false;
         }
     }
     return parent::can($ID, $right, $input);
 }
Ejemplo n.º 4
0
 /**
  * Check right on an item - overloaded to check user access to its datas
  *
  * @param $ID ID of the item (-1 if new item)
  * @param $right Right to check : r / w / recursive
  * @param $input array of input data (used for adding item)
  *
  * @return boolean
  **/
 function can($ID, $right, &$input = NULL)
 {
     if ($ID > 0) {
         if ($this->fields['users_id'] === getLoginUserID()) {
             return true;
         }
     }
     return parent::can($ID, $right, $input);
 }