Example #1
0
 /**
  * Hook called After an item is purge
  */
 static function cleanForItem(CommonDBTM $item)
 {
     $type = get_class($item);
     $temp = new PluginProjetProjet_Item();
     $temp->deleteByCriteria(array('itemtype' => $type, 'items_id' => $item->getField('id')));
     $task = new PluginProjetTask_Item();
     $task->deleteByCriteria(array('itemtype' => $type, 'items_id' => $item->getField('id')));
 }
Example #2
0
 /**
  * Duplicate task of projects from an item template to its clone
  *
  * @since version 0.84
  *
  * @param $itemtype     itemtype of the item
  * @param $oldid        ID of the item to clone
  * @param $newid        ID of the item cloned
  * @param $newitemtype  itemtype of the new item (= $itemtype if empty) (default '')
  **/
 static function cloneItem($oldid, $newid)
 {
     $task_item = new PluginProjetTask_Item();
     $task_task = new PluginProjetTask_Task();
     $restrict = "`plugin_projet_projets_id` = '" . $oldid . "'\n                  AND is_deleted != 1";
     $ptasks = getAllDatasFromTable("glpi_plugin_projet_tasks", $restrict);
     if (!empty($ptasks)) {
         foreach ($ptasks as $ptask) {
             $task = new self();
             $values = $ptask;
             $taskid = $values["id"];
             unset($values["id"]);
             $values["plugin_projet_projets_id"] = $newid;
             $values["name"] = addslashes($ptask["name"]);
             $values["comment"] = addslashes($ptask["comment"]);
             $values["sub"] = addslashes($ptask["sub"]);
             $values["others"] = addslashes($ptask["others"]);
             $values["affect"] = addslashes($ptask["affect"]);
             $newtid = $task->add($values);
             $restrictitems = "`plugin_projet_tasks_id` = '" . $taskid . "'";
             $tasksitems = getAllDatasFromTable("glpi_plugin_projet_tasks_items", $restrictitems);
             if (!empty($tasksitems)) {
                 foreach ($tasksitems as $tasksitem) {
                     $task_item->add(array('plugin_projet_tasks_id' => $newtid, 'itemtype' => $tasksitem["itemtype"], 'items_id' => $tasksitem["items_id"]));
                 }
             }
             /*$restrictlnk = "`plugin_projet_tasks_id_1` = '".$taskid."'";
               $links = getAllDatasFromTable("glpi_plugin_projet_tasks_tasks",$restrictlnk);
               if (!empty($links)) {
                  foreach ($links as $link) {
                     $task_task->add(array('plugin_projet_tasks_id_1' => $newtid,
                                             'plugin_projet_tasks_id_2' => $link["plugin_projet_tasks_id_2"],
                                             'link' => PluginProjetTask_Task::LINK_TO));
                  }
               }
               
               $restrictlnk2 = "`plugin_projet_tasks_id_2` = '".$taskid."'";
               $links2 = getAllDatasFromTable("glpi_plugin_projet_tasks_tasks",$restrictlnk2);
               if (!empty($links2)) {
                  foreach ($links2 as $link2) {
                     $task_task->add(array('plugin_projet_tasks_id_1' => $link2["plugin_projet_tasks_id_1"],
                                             'plugin_projet_tasks_id_2' => $newtid,
                                             'link' => PluginProjetTask_Task::LINK_TO));
                  }
               }*/
         }
     }
 }
Example #3
0
You should have received a copy of the GNU General Public License
along with Projet. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
if (!isset($_GET["id"])) {
    $_GET["id"] = "";
}
if (!isset($_GET["withtemplate"])) {
    $_GET["withtemplate"] = "";
}
if (!isset($_GET["plugin_projet_projets_id"])) {
    $_GET["plugin_projet_projets_id"] = 0;
}
$task = new PluginProjetTask();
$task_item = new PluginProjetTask_Item();
$task_task = new PluginProjetTask_Task();
//add tasks
if (isset($_POST['add'])) {
    $task->check(-1, 'w', $_POST);
    $newID = $task->add($_POST);
    Html::back();
} else {
    if (isset($_POST["update"])) {
        $task->check($_POST['id'], 'w');
        $task->update($_POST);
        Html::back();
    } else {
        if (isset($_POST["delete"])) {
            $task->check($_POST['id'], 'w');
            $task->delete($_POST);