Ejemplo n.º 1
0
 function saveTaskPeekAction()
 {
     @($id = DevblocksPlatform::importGPC($_REQUEST['id'], 'integer', ''));
     @($view_id = DevblocksPlatform::importGPC($_REQUEST['view_id'], 'string', ''));
     @($link_namespace = DevblocksPlatform::importGPC($_REQUEST['link_namespace'], 'string', ''));
     @($link_object_id = DevblocksPlatform::importGPC($_REQUEST['link_object_id'], 'integer', 0));
     @($do_delete = DevblocksPlatform::importGPC($_REQUEST['do_delete'], 'integer', 0));
     $active_worker = CerberusApplication::getActiveWorker();
     if (!empty($id) && !empty($do_delete)) {
         // delete
         $task = DAO_Task::get($id);
         // Check privs
         if ($active_worker->hasPriv('core.tasks.actions.create') && $active_worker->id == $task->worker_id || $active_worker->hasPriv('core.tasks.actions.update_nobody') && empty($task->worker_id) || $active_worker->hasPriv('core.tasks.actions.update_all')) {
             DAO_Task::delete($id);
         }
     } else {
         // create|update
         $fields = array();
         // Title
         @($title = DevblocksPlatform::importGPC($_REQUEST['title'], 'string', ''));
         if (!empty($title)) {
             $fields[DAO_Task::TITLE] = $title;
         }
         // Completed
         @($completed = DevblocksPlatform::importGPC($_REQUEST['completed'], 'integer', 0));
         $fields[DAO_Task::IS_COMPLETED] = intval($completed);
         // [TODO] This shouldn't constantly update the completed date (it should compare)
         if ($completed) {
             $fields[DAO_Task::COMPLETED_DATE] = time();
         } else {
             $fields[DAO_Task::COMPLETED_DATE] = 0;
         }
         // Due Date
         @($due_date = DevblocksPlatform::importGPC($_REQUEST['due_date'], 'string', ''));
         @($fields[DAO_Task::DUE_DATE] = empty($due_date) ? 0 : intval(strtotime($due_date)));
         // Worker
         @($worker_id = DevblocksPlatform::importGPC($_REQUEST['worker_id'], 'integer', 0));
         @($fields[DAO_Task::WORKER_ID] = intval($worker_id));
         // Content
         @($content = DevblocksPlatform::importGPC($_REQUEST['content'], 'string', ''));
         @($fields[DAO_Task::CONTENT] = $content);
         // Link to object (optional)
         if (!empty($link_namespace) && !empty($link_object_id)) {
             @($fields[DAO_Task::SOURCE_EXTENSION] = $link_namespace);
             @($fields[DAO_Task::SOURCE_ID] = $link_object_id);
         }
         // Save
         if (!empty($id)) {
             DAO_Task::update($id, $fields);
         } else {
             $id = DAO_Task::create($fields);
             // Write a notification (if not assigned to ourselves)
             //				$url_writer = DevblocksPlatform::getUrlService();
             $source_extensions = DevblocksPlatform::getExtensions('cerberusweb.task.source', true);
             if (!empty($worker_id)) {
                 // && $active_worker->id != $worker_id (Temporarily allow self notifications)
                 if (null != @($source_renderer = $source_extensions[$link_namespace])) {
                     /* @var $source_renderer Extension_TaskSource */
                     $source_info = $source_renderer->getSourceInfo($link_object_id);
                     $source_name = $source_info['name'];
                     $source_url = $source_info['url'];
                     if (empty($source_name) || empty($source_url)) {
                         break;
                     }
                     $fields = array(DAO_WorkerEvent::CREATED_DATE => time(), DAO_WorkerEvent::WORKER_ID => $worker_id, DAO_WorkerEvent::URL => $source_url, DAO_WorkerEvent::TITLE => 'New Task Assignment', DAO_WorkerEvent::CONTENT => sprintf("%s\n%s says: %s", $source_name, $active_worker->getName(), $title), DAO_WorkerEvent::IS_READ => 0);
                     DAO_WorkerEvent::create($fields);
                 }
             }
         }
         // Custom field saves
         @($field_ids = DevblocksPlatform::importGPC($_POST['field_ids'], 'array', array()));
         DAO_CustomFieldValue::handleFormPost(ChCustomFieldSource_Task::ID, $id, $field_ids);
     }
     if (!empty($view_id) && null != ($view = C4_AbstractViewLoader::getView('', $view_id))) {
         $view->render();
     }
     exit;
 }
Ejemplo n.º 2
0
 private function _putIdAction($path)
 {
     $xmlstr = $this->getPayload();
     $xml_in = new SimpleXMLElement($xmlstr);
     $in_id = array_shift($path);
     if (empty($in_id)) {
         $this->_error("ID was not provided.");
     }
     if (null == ($task = DAO_Task::get($in_id))) {
         $this->_error("ID not valid.");
     }
     $fields = array();
     $flds = SearchFields_Task::getFields();
     unset($flds[DAO_Task::ID]);
     foreach ($flds as $idx => $f) {
         $idx_name = $this->translate($idx, true);
         if ($idx_name == null) {
             continue;
         }
         @($value = DevblocksPlatform::importGPC($xml_in->{$idx_name}, 'string'));
         if ($this->isValid($idx_name, $value)) {
             $fields[$idx_name] = $value;
         }
     }
     if (!empty($fields)) {
         DAO_Task::update($task->id, $fields);
     }
     $this->_getIdAction(array($task->id));
 }
Ejemplo n.º 3
0
 function saveTasksPropertiesTabAction()
 {
     @($id = DevblocksPlatform::importGPC($_REQUEST['id'], 'integer', ''));
     @($do_delete = DevblocksPlatform::importGPC($_REQUEST['do_delete'], 'integer', 0));
     $active_worker = CerberusApplication::getActiveWorker();
     if (!empty($id) && !empty($do_delete)) {
         // delete
         $task = DAO_Task::get($id);
         // Check privs
         if ($active_worker->hasPriv('core.tasks.actions.create') && $active_worker->id == $task->worker_id || $active_worker->hasPriv('core.tasks.actions.update_nobody') && empty($task->worker_id) || $active_worker->hasPriv('core.tasks.actions.update_all')) {
             DAO_Task::delete($id);
             DevblocksPlatform::redirect(new DevblocksHttpResponse(array('activity', 'tasks')));
             exit;
         }
     } else {
         // update
         $fields = array();
         // Title
         @($title = DevblocksPlatform::importGPC($_REQUEST['title'], 'string', ''));
         $fields[DAO_Task::TITLE] = !empty($title) ? $title : 'New Task';
         // Completed
         @($completed = DevblocksPlatform::importGPC($_REQUEST['completed'], 'integer', 0));
         $fields[DAO_Task::IS_COMPLETED] = intval($completed);
         // [TODO] This shouldn't constantly update the completed date (it should compare)
         if ($completed) {
             $fields[DAO_Task::COMPLETED_DATE] = time();
         } else {
             $fields[DAO_Task::COMPLETED_DATE] = 0;
         }
         // Updated Date
         $fields[DAO_Task::UPDATED_DATE] = time();
         // Due Date
         @($due_date = DevblocksPlatform::importGPC($_REQUEST['due_date'], 'string', ''));
         @($fields[DAO_Task::DUE_DATE] = empty($due_date) ? 0 : intval(strtotime($due_date)));
         // Worker
         @($worker_id = DevblocksPlatform::importGPC($_REQUEST['worker_id'], 'integer', 0));
         @($fields[DAO_Task::WORKER_ID] = intval($worker_id));
         // Save
         if (!empty($id)) {
             DAO_Task::update($id, $fields);
             // Custom field saves
             @($field_ids = DevblocksPlatform::importGPC($_POST['field_ids'], 'array', array()));
             DAO_CustomFieldValue::handleFormPost(ChCustomFieldSource_Task::ID, $id, $field_ids);
         }
     }
     DevblocksPlatform::redirect(new DevblocksHttpResponse(array('tasks', 'display', $id, 'properties')));
 }
Ejemplo n.º 4
0
 function doBulkUpdate($filter, $do, $ids = array())
 {
     @set_time_limit(600);
     // [TODO] Temp!
     $change_fields = array();
     $custom_fields = array();
     // Make sure we have actions
     if (empty($do)) {
         return;
     }
     // Make sure we have checked items if we want a checked list
     if (0 == strcasecmp($filter, "checks") && empty($ids)) {
         return;
     }
     if (is_array($do)) {
         foreach ($do as $k => $v) {
             switch ($k) {
                 case 'due':
                     @($date = strtotime($v));
                     $change_fields[DAO_Task::DUE_DATE] = intval($date);
                     break;
                 case 'status':
                     if (1 == intval($v)) {
                         // completed
                         $change_fields[DAO_Task::IS_COMPLETED] = 1;
                         $change_fields[DAO_Task::COMPLETED_DATE] = time();
                     } else {
                         // active
                         $change_fields[DAO_Task::IS_COMPLETED] = 0;
                         $change_fields[DAO_Task::COMPLETED_DATE] = 0;
                     }
                     break;
                 case 'worker_id':
                     $change_fields[DAO_Task::WORKER_ID] = intval($v);
                     break;
                 default:
                     // Custom fields
                     if (substr($k, 0, 3) == "cf_") {
                         $custom_fields[substr($k, 3)] = $v;
                     }
             }
         }
     }
     $pg = 0;
     if (empty($ids)) {
         do {
             list($objects, $null) = DAO_Task::search(array(), $this->params, 100, $pg++, SearchFields_Task::ID, true, false);
             $ids = array_merge($ids, array_keys($objects));
         } while (!empty($objects));
     }
     $batch_total = count($ids);
     for ($x = 0; $x <= $batch_total; $x += 100) {
         $batch_ids = array_slice($ids, $x, 100);
         DAO_Task::update($batch_ids, $change_fields);
         // Custom Fields
         self::_doBulkSetCustomFields(ChCustomFieldSource_Task::ID, $custom_fields, $batch_ids);
         unset($batch_ids);
     }
     unset($ids);
 }
Ejemplo n.º 5
0
 function runMacroAction()
 {
     @($macro_id = DevblocksPlatform::importGPC($_REQUEST['macro_id'], 'integer'));
     @($ids = DevblocksPlatform::importGPC($_REQUEST['ids']));
     @($view_id = DevblocksPlatform::importGPC($_REQUEST['view_id'], 'string'));
     $view = C4_AbstractViewLoader::getView($view_id);
     $ids = explode(',', $ids);
     if (null !== ($macro = DAO_Macro::get($macro_id))) {
         switch ($macro->source_extension_id) {
             case 'cerberusweb.macros.ticket':
                 $fields = array();
                 // loop over the actions, saving the $params as $fields
                 foreach ($macro->actions as $action => $params) {
                     switch ($action) {
                         case 'cerberusweb.macros.action.assign':
                             $fields['next_worker_id'] = $params['worker_id'];
                             break;
                         case 'cerberusweb.macros.action.move':
                             $fields['team_id'] = $params['group_id'];
                             $fields['category_id'] = $params['bucket_id'];
                             break;
                         case 'cerberusweb.macros.action.status':
                             $fields['is_waiting'] = $params['is_waiting'];
                             $fields['is_closed'] = $params['is_closed'];
                             $fields['is_deleted'] = $params['is_deleted'];
                             break;
                         default:
                             //								$fields[] = $params;
                             break;
                     }
                 }
                 // update the ticket
                 DAO_Ticket::updateTicket($ids, $fields);
                 break;
             case 'cerberusweb.macros.address':
                 foreach ($macro->actions as $action => $params) {
                     switch ($action) {
                         default:
                             DAO_Address::update($ids, $params);
                     }
                 }
                 break;
             case 'cerberusweb.macros.opportunity':
                 foreach ($macro->actions as $action => $params) {
                     switch ($action) {
                         default:
                             DAO_CrmOpportunity::update($ids, $params);
                     }
                 }
             case 'cerberusweb.macros.task':
                 foreach ($macro->actions as $action => $params) {
                     switch ($action) {
                         default:
                             DAO_Task::update($ids, $params);
                     }
                 }
             case 'cerberusweb.macros.organization':
                 foreach ($macro->actions as $action => $params) {
                     switch ($action) {
                         default:
                             DAO_ContactOrg::update($ids, $params);
                     }
                 }
             default:
                 break;
         }
     }
     $view = C4_AbstractViewLoader::getView($view_id);
     $view->render();
 }