public function deleteByObject($object_id) { $q = new w2p_Database_Query(); $q->setDelete('custom_fields_values'); $q->addWhere('value_object_id=' . (int) $object_id); $q->exec(); }
public function delete() { $q = new w2p_Database_Query(); $q->setDelete('custom_fields_lists'); $q->addWhere('field_id = ' . (int) $this->field_id); $q->addWhere('list_option_id = ' . (int) $this->list_option_id); return $q->exec(); }
public function remove() { $q = new w2p_Database_Query(); $q->dropTable('links'); $q->exec(); $q->clear(); $q->setDelete('sysvals'); $q->addWhere('sysval_title = \'LinkType\''); $q->exec(); }
public function store(CAppUI $AppUI = null) { global $AppUI; $perms = $AppUI->acl(); $stored = false; $this->_error = $this->check(); if (count($this->_error)) { return $this->_error; } $q = new w2p_Database_Query(); if ($this->message_id && $perms->checkModuleItem('forums', 'edit', $this->forum_id)) { $q->setDelete('forum_visits'); $q->addWhere('visit_message = ' . (int) $this->message_id); $q->exec(); if ($msg = parent::store()) { return $msg; } $stored = true; } if (0 == $this->message_id && $perms->checkModuleItem('forums', 'add')) { $this->message_date = $q->dbfnNowWithTZ(); if ($msg = parent::store()) { return $msg; } $q->addTable('forum_messages'); $q->addQuery('count(message_id), MAX(message_date)'); $q->addWhere('message_forum = ' . (int) $this->message_forum); $reply = $q->fetchRow(); //update forum descriptor $forum = new CForum(); $forum->load($AppUI, $this->message_forum); $forum->forum_message_count = $reply[0]; /* * Note: the message_date here has already been adjusted for the * timezone above, so don't do it again! */ $forum->forum_last_date = $this->message_date; $forum->forum_last_id = $this->message_id; $forum->store($AppUI); $this->sendWatchMail(false); $stored = true; } return $stored; }
public static function unpinUserTask($userId, $taskId) { $q = new w2p_Database_Query(); $q->setDelete('user_task_pin'); $q->addWhere('user_id = ' . (int) $userId); $q->addWhere('task_id = ' . (int) $taskId); if (!$q->exec()) { return 'Error unpinning task'; } else { return true; } }
/* $Id: do_watch_forum.php 1595 2011-01-17 07:37:10Z caseydk $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/tags/version2.4/modules/forums/do_watch_forum.php $ */ if (!defined('W2P_BASE_DIR')) { die('You should not access this file directly.'); } $perms =& $AppUI->acl(); if (!canView('forums')) { $AppUI->redirect('m=public&a=access_denied'); } ## ## Change forum watches ## $watch = w2PgetParam($_POST, 'watch', ''); if ($watch) { // clear existing watches $q = new w2p_Database_Query(); $q->setDelete('forum_watch'); $q->addWhere('watch_user = '******'watch_' . $watch . ' IS NOT NULL'); if (!$q->exec()) { $AppUI->setMsg(db_error(), UI_MSG_ERROR); $q->clear(); } else { $q->clear(); foreach ($_POST as $k => $v) { if (strpos($k, 'forum_') !== false) { $q->addTable('forum_watch'); $q->addInsert('watch_user', $AppUI->user_id); $q->addInsert('watch_' . $watch, substr($k, 6)); if (!$q->exec()) { $AppUI->setMsg(db_error(), UI_MSG_ERROR); } else {
function projects_list_data($user_id = false) { global $AppUI, $addPwOiD, $buffer, $company, $company_id, $company_prefix, $deny, $department, $dept_ids, $w2Pconfig, $orderby, $orderdir, $tasks_problems, $owner, $projectTypeId, $search_text, $project_type; $addProjectsWithAssignedTasks = $AppUI->getState('addProjWithTasks') ? $AppUI->getState('addProjWithTasks') : 0; // get any records denied from viewing $obj = new CProject(); $deny = $obj->getDeniedRecords($AppUI->user_id); // Let's delete temproary tables $q = new w2p_Database_Query(); $q->setDelete('tasks_problems'); $q->exec(); $q->clear(); $q->setDelete('tasks_users'); $q->exec(); $q->clear(); // support task problem logs $q->addInsertSelect('tasks_problems'); $q->addTable('tasks'); $q->addQuery('task_project, task_log_problem'); $q->addJoin('task_log', 'tl', 'tl.task_log_task = task_id', 'inner'); $q->addWhere('task_log_problem = 1'); $q->addGroup('task_project'); $tasks_problems = $q->exec(); $q->clear(); if ($addProjectsWithAssignedTasks) { // support users tasks $q->addInsertSelect('tasks_users'); $q->addTable('tasks'); $q->addQuery('task_project'); $q->addQuery('ut.user_id'); $q->addJoin('user_tasks', 'ut', 'ut.task_id = tasks.task_id'); if ($user_id) { $q->addWhere('ut.user_id = ' . (int) $user_id); } $q->addOrder('task_end_date DESC'); $q->addGroup('task_project'); $tasks_users = $q->exec(); $q->clear(); } // add Projects where the Project Owner is in the given department if ($addPwOiD && isset($department)) { $owner_ids = array(); $q->addTable('users'); $q->addQuery('user_id'); $q->addJoin('contacts', 'c', 'c.contact_id = user_contact', 'inner'); $q->addWhere('c.contact_department = ' . (int) $department); $owner_ids = $q->loadColumn(); $q->clear(); } if (isset($department)) { //If a department is specified, we want to display projects from the department, and all departments under that, so we need to build that list of departments $dept_ids = array(); $q->addTable('departments'); $q->addQuery('dept_id, dept_parent'); $q->addOrder('dept_parent,dept_name'); $rows = $q->loadList(); addDeptId($rows, $department); $dept_ids[] = isset($department->dept_id) ? $department->dept_id : 0; $dept_ids[] = $department > 0 ? $department : 0; } $q->clear(); // retrieve list of records // modified for speed // by Pablo Roca (pabloroca@mvps.org) // 16 August 2003 // get the list of permitted companies $obj = new CCompany(); $companies = $obj->getAllowedRecords($AppUI->user_id, 'companies.company_id,companies.company_name', 'companies.company_name'); if (count($companies) == 0) { $companies = array(); } $q->addTable('projects', 'pr'); $q->addQuery('pr.project_id, project_status, project_color_identifier, project_type, project_name, project_description, project_scheduled_hours as project_duration, project_parent, project_original_parent, project_percent_complete, project_color_identifier, project_company, company_name, project_status, project_last_task as critical_task, tp.task_log_problem, user_username, project_active'); $fields = w2p_Core_Module::getSettings('projects', 'index_list'); unset($fields['department_list']); // added as an alias below foreach ($fields as $field => $text) { $q->addQuery($field); } $q->addQuery('CONCAT(ct.contact_first_name, \' \', ct.contact_last_name) AS owner_name'); $q->addJoin('users', 'u', 'pr.project_owner = u.user_id'); $q->addJoin('contacts', 'ct', 'ct.contact_id = u.user_contact'); $q->addJoin('tasks_problems', 'tp', 'pr.project_id = tp.task_project'); if ($addProjectsWithAssignedTasks) { $q->addJoin('tasks_users', 'tu', 'pr.project_id = tu.task_project'); } if (!isset($department) && $company_id && !$addPwOiD) { $q->addWhere('pr.project_company = ' . (int) $company_id); } if ($project_type > -1) { $q->addWhere('pr.project_type = ' . (int) $project_type); } if (isset($department) && !$addPwOiD) { $q->addWhere('project_departments.department_id in ( ' . implode(',', $dept_ids) . ' )'); } if ($user_id && $addProjectsWithAssignedTasks) { $q->addWhere('(tu.user_id = ' . (int) $user_id . ' OR pr.project_owner = ' . (int) $user_id . ' )'); } elseif ($user_id) { $q->addWhere('pr.project_owner = ' . (int) $user_id); } if ($owner > 0) { $q->addWhere('pr.project_owner = ' . (int) $owner); } if (mb_trim($search_text)) { $q->addWhere('pr.project_name LIKE \'%' . $search_text . '%\' OR pr.project_description LIKE \'%' . $search_text . '%\''); } // Show Projects where the Project Owner is in the given department if ($addPwOiD && !empty($owner_ids)) { $q->addWhere('pr.project_owner IN (' . implode(',', $owner_ids) . ')'); } $orderby = 'project_company' == $orderby ? 'company_name' : $orderby; $q->addGroup('pr.project_id'); $q->addOrder($orderby . ' ' . $orderdir); $prj = new CProject(); $prj->setAllowedSQL($AppUI->user_id, $q, null, 'pr'); $dpt = new CDepartment(); $projects = $q->loadList(); // get the list of permitted companies $companies = arrayMerge(array('0' => $AppUI->_('All')), $companies); $company_array = $companies; //get list of all departments, filtered by the list of permitted companies. $q->clear(); $q->addTable('companies'); $q->addQuery('company_id, company_name, dep.*'); $q->addJoin('departments', 'dep', 'companies.company_id = dep.dept_company'); $q->addOrder('company_name,dept_parent,dept_name'); $obj->setAllowedSQL($AppUI->user_id, $q); $dpt->setAllowedSQL($AppUI->user_id, $q); $rows = $q->loadList(); //display the select list $buffer = '<select name="department" id="department" onChange="document.pickCompany.submit()" class="text" style="width: 200px;">'; $company = ''; foreach ($company_array as $key => $c_name) { $buffer .= '<option value="' . $company_prefix . $key . '" style="font-weight:bold;"' . ($company_id == $key ? 'selected="selected"' : '') . '>' . $c_name . '</option>' . "\n"; foreach ($rows as $row) { if ($row['dept_parent'] == 0) { if ($key == $row['company_id']) { if ($row['dept_parent'] != null) { findchilddept($rows, $row['dept_id']); } } } } } $buffer .= '</select>'; return $projects; }
public function delete() { $q = new w2p_Database_Query(); if ($this->sysval_title) { $q->setDelete('sysvals'); $q->addWhere('sysval_title = \'' . $this->sysval_title . '\''); if (!$q->exec()) { $q->clear(); return get_class($this) . '::delete failed <br />' . db_error(); } } return null; }
public function delete(CAppUI $AppUI = null) { global $AppUI; global $helpdesk_available; $perms = $AppUI->acl(); $this->_error = array(); if ($perms->checkModuleItem('files', 'delete', $this->file_id)) { // remove the file from the file system if (!$this->deleteFile($AppUI)) { return false; } if ($msg = parent::delete()) { return $msg; } // delete any index entries $q = new w2p_Database_Query(); $q->setDelete('files_index'); $q->addQuery('*'); $q->addWhere('file_id = ' . (int) $this->file_id); if (!$q->exec()) { $q->clear(); return db_error(); } if ($helpdesk_available && $this->file_helpdesk_item != 0) { $this->addHelpDeskTaskLog(); } return true; } return false; }
public function commit_updates() { $q = new w2p_Database_Query(); if (count($this->delete_list)) { $q->setDelete($this->table); $q->addWhere('queue_id IN (' . implode(',', $this->delete_list) . ')'); $q->exec(); $q->clear(); } $this->delete_list = array(); foreach ($this->update_list as $fields) { $q->addTable($this->table); $q->addUpdate('queue_repeat_count', $fields['queue_repeat_count']); $q->addUpdate('queue_start', $fields['queue_start']); $q->addWhere('queue_id = ' . $fields['queue_id']); $q->exec(); $q->clear(); } $this->update_list = array(); }
public function updateAssigned($assigned) { // First remove the assigned from the user_events table global $AppUI; $q = new w2p_Database_Query(); $q->setDelete('user_events'); $q->addWhere('event_id = ' . (int) $this->event_id); $q->exec(); $q->clear(); if (is_array($assigned) && count($assigned)) { foreach ($assigned as $uid) { if ($uid) { $q->addTable('user_events', 'ue'); $q->addInsert('event_id', $this->event_id); $q->addInsert('user_id', (int) $uid); $q->exec(); $q->clear(); } } if ($msg = db_error()) { $AppUI->setMsg($msg, UI_MSG_ERROR); } } }
public function delete(CAppUI $AppUI = null) { global $AppUI; $perms = $AppUI->acl(); $this->_error = array(); if ($perms->checkModuleItem('forums', 'delete', $this->forum_id)) { $q = new w2p_Database_Query(); $q->setDelete('forum_visits'); $q->addWhere('visit_forum = ' . (int) $this->forum_id); $q->exec(); // No error if this fails, it is not important. $q->clear(); $q->setDelete('forum_messages'); $q->addWhere('message_forum = ' . (int) $this->forum_id); if (!$q->exec()) { return db_error(); } if ($msg = parent::delete()) { return $msg; } return true; } return false; }
/** * postsave functions are only called after a succesful save. They are * used to perform database operations after the event. */ function resource_postsave() { global $other_resources; global $obj; $task_id = $obj->task_id; if (isset($other_resources)) { $value = array(); $reslist = explode(';', $other_resources); foreach ($reslist as $res) { if ($res) { list($resource, $perc) = explode('=', $res); $value[] = array($task_id, $resource, $perc); } } // first delete any elements already there, then replace with this // list. $q = new w2p_Database_Query(); $q->setDelete('resource_tasks'); $q->addWhere('task_id = ' . (int) $obj->task_id); $q->exec(); $q->clear(); if (count($value)) { foreach ($value as $v) { $q->addTable('resource_tasks'); $q->addInsert('task_id,resource_id,percent_allocated', $v, true); $q->exec(); $q->clear(); } } } }
public function gc() { global $AppUI; $max = $this->convertTime('max_lifetime'); $idle = $this->convertTime('idle_time'); // First pass is to kill any users that are logged in at the time of the session. $where = 'UNIX_TIMESTAMP() - UNIX_TIMESTAMP(session_updated) > ' . $idle . ' OR UNIX_TIMESTAMP() - UNIX_TIMESTAMP(session_created) > ' . $max; $q = new w2p_Database_Query(); $q->addTable('user_access_log'); $q->addUpdate('date_time_out', $q->dbfnNowWithTZ()); $q2 = new w2p_Database_Query(); $q2->addTable('sessions'); $q2->addQuery('session_user'); $q2->addWhere($where); $q->addWhere('user_access_log_id IN ( ' . $q2->prepare() . ' )'); $q->exec(); $q->clear(); $q2->clear(); // Now we simply delete the expired sessions. $q->setDelete('sessions'); $q->addWhere($where); $q->exec(); $q->clear(); if (w2PgetConfig('session_gc_scan_queue')) { // We need to scan the event queue. If $AppUI isn't created yet // And it isn't likely that it will be, we create it and run the // queue scanner. if (!isset($AppUI)) { $AppUI = new w2p_Core_CAppUI(); $queue = new w2p_System_EventQueue(); $queue->scan(); } } return true; }
public function delete(CAppUI $AppUI = null) { global $AppUI; $perms = $AppUI->acl(); $result = false; $this->_error = array(); if ($perms->checkModuleItem('forums', 'delete', $this->project_id)) { $q = new w2p_Database_Query(); $q->setDelete('forum_visits'); $q->addWhere('visit_message = ' . (int) $this->message_id); $q->exec(); // No error if this fails, it is not important. $q->clear(); $q->addTable('forum_messages'); $q->addQuery('message_forum'); $q->addWhere('message_id = ' . (int) $this->message_id); $forumId = $q->loadResult(); $q->clear(); $q->setDelete('forum_messages'); $q->addWhere('message_id = ' . (int) $this->message_id); if (!$q->exec()) { $result = db_error(); } else { $result = null; } $q->clear(); $q->addTable('forum_messages'); $q->addQuery('COUNT(message_id)'); $q->addWhere('message_forum = ' . (int) $forumId); $messageCount = $q->loadResult(); $q->clear(); $q->addTable('forums'); $q->addUpdate('forum_message_count', $messageCount); $q->addWhere('forum_id = ' . (int) $forumId); $q->exec(); $result = true; } return $result; }
public function store(CAppUI $AppUI = null) { global $AppUI; $perms = $AppUI->acl(); $stored = false; $this->w2PTrimAll(); // ensure changes of state in checkboxes is captured $this->project_active = (int) $this->project_active; $this->project_private = (int) $this->project_private; $this->project_target_budget = filterCurrency($this->project_target_budget); $this->project_actual_budget = filterCurrency($this->project_actual_budget); // Make sure project_short_name is the right size (issue for languages with encoded characters) $this->project_short_name = mb_substr($this->project_short_name, 0, 10); if (empty($this->project_end_date)) { $this->project_end_date = null; } $this->_error = $this->check(); if (count($this->_error)) { return $this->_error; } $this->project_id = (int) $this->project_id; // convert dates to SQL format first if ($this->project_start_date) { $date = new w2p_Utilities_Date($this->project_start_date); $this->project_start_date = $date->format(FMT_DATETIME_MYSQL); } if ($this->project_end_date) { $date = new w2p_Utilities_Date($this->project_end_date); $date->setTime(23, 59, 59); $this->project_end_date = $date->format(FMT_DATETIME_MYSQL); } if ($this->project_actual_end_date) { $date = new w2p_Utilities_Date($this->project_actual_end_date); $this->project_actual_end_date = $date->format(FMT_DATETIME_MYSQL); } // check project parents and reset them to self if they do not exist if (!$this->project_parent) { $this->project_parent = $this->project_id; $this->project_original_parent = $this->project_id; } else { $parent_project = new CProject(); $parent_project->load($this->project_parent); $this->project_original_parent = $parent_project->project_original_parent; } if (!$this->project_original_parent) { $this->project_original_parent = $this->project_id; } /* * TODO: I don't like the duplication on each of these two branches, but I * don't have a good idea on how to fix it at the moment... */ $q = new w2p_Database_Query(); $this->project_updated = $q->dbfnNowWithTZ(); if ($this->project_id && $perms->checkModuleItem('projects', 'edit', $this->project_id)) { if ($msg = parent::store()) { return $msg; } $stored = true; } if (0 == $this->project_id && $perms->checkModuleItem('projects', 'add')) { $this->project_created = $q->dbfnNowWithTZ(); if ($msg = parent::store()) { return $msg; } if (0 == $this->project_parent || 0 == $this->project_original_parent) { $this->project_parent = $this->project_id; $this->project_original_parent = $this->project_id; if ($msg = parent::store()) { return $msg; } } $stored = true; } //split out related departments and store them seperatly. $q = new w2p_Database_Query(); $q->setDelete('project_departments'); $q->addWhere('project_id=' . (int) $this->project_id); $q->exec(); $q->clear(); if ($this->project_departments) { foreach ($this->project_departments as $department) { if ($department) { $q->addTable('project_departments'); $q->addInsert('project_id', $this->project_id); $q->addInsert('department_id', $department); $q->exec(); $q->clear(); } } } //split out related contacts and store them seperatly. $q->setDelete('project_contacts'); $q->addWhere('project_id=' . (int) $this->project_id); $q->exec(); $q->clear(); if ($this->project_contacts) { foreach ($this->project_contacts as $contact) { if ($contact) { $q->addTable('project_contacts'); $q->addInsert('project_id', $this->project_id); $q->addInsert('contact_id', $contact); $q->exec(); $q->clear(); } } } if ($stored) { $custom_fields = new w2p_Core_CustomFields('projects', 'addedit', $this->project_id, 'edit'); $custom_fields->bind($_POST); $sql = $custom_fields->store($this->project_id); // Store Custom Fields CTask::storeTokenTask($AppUI, $this->project_id); } return $stored; }
public static function saveSettings($moduleName, $configName, $displayColumns, $displayOrder, $configValue, $configText) { if ('' == $moduleName || '' == $configName) { return false; } $q = new w2p_Database_Query(); $q->setDelete('module_config'); $q->addWhere("module_name = '{$moduleName}'"); $q->addWhere("module_config_name = '{$configName}'"); $q->exec(); $q->clear(); $i = 0; foreach ($configValue as $index => $field) { if (isset($displayColumns[$field])) { $q->addTable('module_config'); $q->addInsert('module_name', $moduleName); $q->addInsert('module_config_name', $configName); $q->addInsert('module_config_value', $field); $q->addInsert('module_config_text', $configText[$index]); $q->addInsert('module_config_order', (int) $displayOrder[$field]); $q->exec(); $q->clear(); $i++; } } }
// if task priority set and items selected, do some work $task_priority = w2PgetParam($_POST, 'task_priority', 99); $selected = w2PgetParam($_POST, 'selected_task', 0); if (is_array($selected) && count($selected)) { foreach ($selected as $key => $val) { if ($task_priority == 'c') { // mark task as completed $q = new w2p_Database_Query(); $q->addTable('tasks'); $q->addUpdate('task_percent_complete', '100'); $q->addWhere('task_id=' . (int) $val); } else { if ($task_priority == 'd') { // delete task $q = new w2p_Database_Query(); $q->setDelete('tasks'); $q->addWhere('task_id=' . (int) $val); } else { if ($task_priority > -2 && $task_priority < 2) { // set priority $q = new w2p_Database_Query(); $q->addTable('tasks'); $q->addUpdate('task_priority', $task_priority); $q->addWhere('task_id=' . (int) $val); } } } $q->exec(); echo db_error(); $q->clear(); }
/** * @param $selected * @param $task_priority */ function __extract_from_tasks_todo($selected, $task_priority) { $q = new w2p_Database_Query(); foreach ($selected as $key => $val) { if ($task_priority == 'c') { // mark task as completed $q->addTable('tasks'); $q->addUpdate('task_percent_complete', '100'); $q->addWhere('task_id=' . (int) $val); } else { if ($task_priority == 'd') { // delete task $q->setDelete('tasks'); $q->addWhere('task_id=' . (int) $val); } else { if ($task_priority > -2 && $task_priority < 2) { // set priority $q->addTable('tasks'); $q->addUpdate('task_priority', $task_priority); $q->addWhere('task_id=' . (int) $val); } } } $q->exec(); echo db_error(); $q->clear(); } }
$q->addInsert('history_project', $history_project); $okMsg = 'History added'; } elseif ($action == 'update') { if (!canEdit('history')) { $AppUI->redirect('m=public&a=access_denied'); } $q->addTable('history'); $q->addUpdate('history_description', $history_description); $q->addUpdate('history_project', $history_project); $q->addWhere('history_id =' . $history_id); $okMsg = 'History updated'; } elseif ($action == 'del') { if (!canDelete('history')) { $AppUI->redirect('m=public&a=access_denied'); } $q->setDelete('history'); $q->addWhere('history_id =' . $history_id); $okMsg = 'History deleted'; } if (!$q->exec()) { $AppUI->setMsg(db_error()); } else { $AppUI->setMsg($okMsg); if ($action == 'add') { $q->clear(); } $q->addTable('history'); $q->addUpdate('history_item = history_id'); $q->addWhere('history_table = \'history\''); $okMsg = 'History deleted'; }
public function delete() { $q = new w2p_Database_Query(); $q->setDelete('user_preferences'); $q->addWhere('pref_user = '******'pref_name = \'' . $this->pref_name . '\''); if (!$q->exec()) { $q->clear(); return db_error(); } else { $q->clear(); return null; } }
public function setContactMethods(array $methods) { $q = new w2p_Database_Query(); $q->setDelete('contacts_methods'); $q->addWhere('contact_id=' . (int) $this->contact_id); $q->exec(); $q->clear(); if (!empty($methods)) { $q = new w2p_Database_Query(); $q->addTable('contacts_methods'); $q->addInsert('contact_id', (int) $this->contact_id); foreach ($methods as $name => $value) { if (!empty($value)) { $q->addInsert('method_name', $name); $q->addInsert('method_value', $value); $q->exec(); } } $q->clear(); } }
public function deleteField($field_id) { global $db; $q = new w2p_Database_Query(); $q->setDelete('custom_fields_struct'); $q->addWhere('field_id = ' . $field_id); if (!$q->exec()) { $q->clear(); return $db->ErrorMsg(); } }
public function unregisterModule($module_value) { if ($module_value != '') { $q = new w2p_Database_Query(); $q->setDelete('gacl_axo'); $q->addWhere("value = '{$module_value}'"); $q->exec(); return true; } return false; }
public function remove() { global $AppUI; $q = new w2p_Database_Query(); $q->dropTable('holiday'); $q->exec(); $q->clear(); $q->dropTable('holiday_settings'); $q->exec(); $q->clear(); $q->setDelete('modules'); $q->addWhere("mod_directory = 'holiday'"); $q->exec(); $q->clear(); $q->setDelete('sysvals'); $q->addWhere('sysval_title = \'UserHolidayType\''); $q->exec(); $perms = $AppUI->acl(); return $perms->unregisterModule('holiday'); }
if (is_array($result)) { break; } } } } //Action: Change dependency if (isset($_POST['bulk_task_dependency']) && $bulk_task_dependency != '') { if ($upd_task->task_id) { //If parent is self task //print_r($bulk_task_dependency);die; if ($bulk_task_dependency == '0') { $upd_task->task_dynamic = 0; $upd_task->store($AppUI); $q = new w2p_Database_Query(); $q->setDelete('task_dependencies'); $q->addWhere('dependencies_task_id=' . $upd_task->task_id); $q->exec(); } elseif (!($bulk_task_dependency == $upd_task->task_id)) { $upd_task->task_dynamic = 31; $upd_task->store($AppUI); $q = new w2p_Database_Query(); $q->addTable('task_dependencies'); $q->addReplace('dependencies_task_id', $upd_task->task_id); $q->addReplace('dependencies_req_task_id', $bulk_task_dependency); $q->exec(); //Lets recalc the dependency $dep_task = new CTask(); $dep_task->load($bulk_task_dependency); if ($dep_task->task_id) { $dep_task->shiftDependentTasks();
/** * Default delete method * * Can be overloaded/supplemented by the child class * @return null|string null if successful otherwise returns and error message */ public function delete($oid = null) { $k = $this->_tbl_key; if ($oid) { $this->{$k} = intval($oid); } if (!$this->canDelete($msg)) { return $msg; } $q = new w2p_Database_Query(); $q->setDelete($this->_tbl); $q->addWhere($this->_tbl_key . ' = \'' . $this->{$k} . '\''); $result = !$q->exec() ? db_error() : null; if (!$result) { // only record history if deletion actually occurred addHistory($this->_tbl, $this->{$k}, 'delete'); } $q->clear(); return $result; }
$cols = 13; /**** // Let's figure out which tasks are selected */ $q = new w2p_Database_Query(); $pinned_only = (int) w2PgetParam($_GET, 'pinned', 0); if (isset($_GET['pin'])) { $pin = (int) w2PgetParam($_GET, 'pin', 0); $msg = ''; // load the record data if ($pin) { $q->addTable('user_task_pin'); $q->addInsert('user_id', $AppUI->user_id); $q->addInsert('task_id', $task_id); } else { $q->setDelete('user_task_pin'); $q->addWhere('user_id = ' . (int) $AppUI->user_id); $q->addWhere('task_id = ' . (int) $task_id); } if (!$q->exec()) { $AppUI->setMsg('ins/del err', UI_MSG_ERROR, true); } else { $q->clear(); } $AppUI->redirect('', -1); } $AppUI->savePlace(); $durnTypes = w2PgetSysVal('TaskDurationType'); $taskPriority = w2PgetSysVal('TaskPriority'); $task_project = $project_id; $task_sort_item1 = w2PgetParam($_GET, 'task_sort_item1', '');
public static function generateUserToken($userId, $token = '') { $q = new w2p_Database_Query(); $q->setDelete('user_feeds'); $q->addWhere('feed_user = '******'{$token}'"); $q->exec(); $q->clear(); $token = md5(time() . $userId . $token . time()); $q->addTable('user_feeds'); $q->addInsert('feed_user', $userId); $q->addInsert('feed_token', $token); $q->exec(); return true; }