Esempio n. 1
0
 /**
  * @see CommonDBTM::doSpecificMassiveActions()
  **/
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case "duplicate":
             // For calendar duplicate in another entity
             if (method_exists($this, 'duplicate')) {
                 $options = array();
                 if ($this->isEntityAssign()) {
                     $options = array('entities_id' => $input['entities_id']);
                 }
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         if ($this->getFromDB($key)) {
                             if (!$this->isEntityAssign() || $input['entities_id'] != $this->getEntityID()) {
                                 if ($this->can(-1, 'w', $options)) {
                                     if ($this->duplicate($options)) {
                                         $res['ok']++;
                                     } else {
                                         $res['ko']++;
                                     }
                                 } else {
                                     $res['noright']++;
                                 }
                             } else {
                                 $res['ko']++;
                             }
                         } else {
                             $res['ko']++;
                         }
                     }
                 }
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
Esempio n. 2
0
 /**
  * @see CommonDBTM::doSpecificMassiveActions()
  **/
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
 /**
  * @see CommonDBTM::doSpecificMassiveActions()
  **/
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case 'move_under':
             if (isset($input['parent'])) {
                 $fk = $this->getForeignKeyField();
                 $parent = new $input["itemtype"]();
                 if ($parent->getFromDB($input['parent'])) {
                     foreach ($input["item"] as $key => $val) {
                         if ($val == 1 && $this->can($key, 'w')) {
                             // Check if parent is not a child of the original one
                             if (!in_array($parent->getID(), getSonsOf($this->getTable(), $this->getID()))) {
                                 if ($this->update(array('id' => $key, $fk => $input['parent']))) {
                                     $res['ok']++;
                                 } else {
                                     $res['ko']++;
                                 }
                             } else {
                                 $res['ko']++;
                             }
                         } else {
                             $res['noright']++;
                         }
                     }
                 }
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }