[ Index ]

Source Code Reference for V1.00

title

Body

[close]

/modules/tasks/ -> do_task_assign_aed.php (source)

   1  <?php /* $Id: do_task_assign_aed.php 168 2008-05-20 11:22:15Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/tasks/do_task_assign_aed.php $ */
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly.');
   4  }
   5  
   6  $del = isset($_POST['del']) ? $_POST['del'] : 0;
   7  $rm = isset($_POST['rm']) ? $_POST['rm'] : 0;
   8  $hassign = $_POST['hassign'];
   9  $htasks = $_POST['htasks'];
  10  $store = w2PgetParam($_POST, 'store', 0);
  11  $chUTP = w2PgetParam($_POST, 'chUTP', 0);
  12  $percentage_assignment = w2PgetParam($_POST, 'percentage_assignment');
  13  $user_task_priority = w2PgetParam($_POST, 'user_task_priority');
  14  $user_id = $_POST['user_id'];
  15  
  16  $perms = &$AppUI->acl();
  17  
  18  // prepare the percentage of assignment per user as required by CTask::updateAssigned()
  19  $hperc_assign_ar = array();
  20  if (isset($hassign)) {
  21      $tarr = explode(',', $hassign);
  22      foreach ($tarr as $uid) {
  23          if (intval($uid) > 0) {
  24              $hperc_assign_ar[$uid] = $percentage_assignment;
  25          }
  26      }
  27  }
  28  
  29  // prepare a list of tasks to process
  30  $htasks_ar = array();
  31  if (isset($htasks)) {
  32      $tarr = explode(',', $htasks);
  33      foreach ($tarr as $tid) {
  34          if (intval($tid) > 0) {
  35              $htasks_ar[] = $tid;
  36          }
  37      }
  38  }
  39  $sizeof = count($htasks_ar);
  40  for ($i = 0; $i <= $sizeof; $i++) {
  41  
  42      $_POST['task_id'] = $htasks_ar[$i];
  43  
  44      // verify that task_id is not NULL
  45      if ($_POST['task_id'] > 0) {
  46          //check permissions, if user does not have permission then fail silently
  47          if (!$perms->checkModuleItem('tasks', 'edit', $_POST['task_id'])) {
  48              continue;
  49          }
  50          
  51          $obj = new CTask();
  52  
  53          if (!$obj->bind($_POST)) {
  54              $AppUI->setMsg($obj->getError(), UI_MSG_ERROR);
  55              $AppUI->redirect();
  56          }
  57  
  58          if ($rm && $del) {
  59              $overAssignment = $obj->updateAssigned($hassign, $hperc_assign_ar, true, true);
  60              if ($overAssignment) {
  61                  $AppUI->setMsg('Some Users could not be unassigned from Task', UI_MSG_ERROR);
  62              }
  63          } elseif (($rm || $del)) {
  64              if (($msg = $obj->removeAssigned($user_id))) {
  65                  $AppUI->setMsg($msg, UI_MSG_ERROR);
  66              } else {
  67                  $AppUI->setMsg('User unassigned from Task', UI_MSG_OK);
  68              }
  69          }
  70          if (isset($hassign) && !$del == 1) {
  71              $overAssignment = $obj->updateAssigned($hassign, $hperc_assign_ar, false, false);
  72              //check if OverAssignment occured, database has not been updated in this case
  73              if ($overAssignment) {
  74                  $AppUI->setMsg('The following Users have not been assigned in order to prevent from Over-Assignment:', UI_MSG_ERROR);
  75                  $AppUI->setMsg('<br>' . $overAssignment, UI_MSG_ERROR, true);
  76              } else {
  77                  $AppUI->setMsg('User(s) assigned to Task', UI_MSG_OK);
  78              }
  79          }
  80          // process the user specific task priority
  81          if ($chUTP == 1) {
  82              $obj->updateUserSpecificTaskPriority($user_task_priority, $user_id);
  83              $AppUI->setMsg('User specific Task Priority updated', UI_MSG_OK, true);
  84          }
  85  
  86          if ($store == 1) {
  87              if (($msg = $obj->store())) {
  88                  $AppUI->setMsg($msg, UI_MSG_ERROR, true);
  89              } else {
  90                  $AppUI->setMsg('Task(s) updated', UI_MSG_OK, true);
  91              }
  92          }
  93      }
  94  }
  95  if ($rm && $del) {
  96      $AppUI->setMsg('User(s) unassigned from Task', UI_MSG_OK);
  97  }
  98  $AppUI->redirect();
  99  ?>


Generated: Thu Jan 8 03:00:03 2009 Cross-referenced by PHPXref 0.7