public function store($unused = null) { $stored = false; $q = $this->_getQuery(); if ($this->{$this->_tbl_key} && $this->canEdit()) { $q->setDelete('forum_visits'); $q->addWhere('visit_message = ' . (int) $this->message_id); $q->exec(); $stored = parent::store(); } if (0 == $this->{$this->_tbl_key} && $this->canCreate()) { $this->message_date = $q->dbfnNowWithTZ(); $stored = parent::store(); if ($stored) { $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->overrideDatabase($this->_query); $forum->load($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(); $this->sendWatchMail(false); } } return $stored; }
public function store(CAppUI $AppUI = null) { global $AppUI; global $helpdesk_available; $perms = $AppUI->acl(); $stored = false; $this->_error = $this->check(); if (count($this->_error)) { return $this->_error; } if ($helpdesk_available && $this->file_helpdesk_item != 0) { $this->addHelpDeskTaskLog(); } $this->file_date = $AppUI->convertToSystemTZ($this->file_date); if ($this->file_id && $perms->checkModuleItem('files', 'edit', $this->file_id)) { // If while editing a file we attach a new file, then we go ahead and set file_id to 0 so a new file object is created. We also set its owner to the current user. // If not then we are just editing the file information alone. So we should leave the file_id as it is. $this->file_parent = $this->file_id; if ((int) $this->file_size > 0) { $this->file_id = 0; $this->file_owner = $AppUI->user_id; } if ($msg = parent::store()) { return $msg; } $stored = true; } if (0 == $this->file_id && $perms->checkModuleItem('files', 'add')) { if ($msg = parent::store()) { return $msg; } $stored = true; } return true; }
public function store(CAppUI $AppUI) { $perms = $AppUI->acl(); $stored = false; $errorMsgArray = $this->check(); if (count($errorMsgArray) > 0) { return $errorMsgArray; } /* * 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... */ if ($this->field_id && canEdit('system')) { if ($msg = parent::store()) { return $msg; } $stored = true; } if (0 == $this->field_id && canEdit('system')) { if ($msg = parent::store()) { return $msg; } $stored = true; } return $stored; }
public function store($notUsed = null, $externally_created_user = false) { $this->externally_created_user = $externally_created_user; if (!$this->isValid()) { return false; } return parent::store(); }
public function store($unused = null) { $stored = false; //TODO: Why isn't there a canCreate branch here? if ($this->canEdit()) { $stored = parent::store(); } return $stored; }
public function store() { global $helpdesk_available; $stored = false; $this->_error = $this->check(); if (count($this->_error)) { return $this->_error; } if ($helpdesk_available && $this->file_helpdesk_item != 0) { $this->addHelpDeskTaskLog(); } if ($this->{$this->_tbl_key} && $this->_perms->checkModuleItem($this->_tbl_module, 'edit', $this->{$this->_tbl_key})) { // If while editing a file we attach a new file, then we go ahead and set file_id to 0 so a new file object is created. We also set its owner to the current user. // If not then we are just editing the file information alone. So we should leave the file_id as it is. $this->file_parent = $this->file_id; if ((int) $this->file_size > 0) { $this->file_id = 0; $this->file_owner = $this->_AppUI->user_id; } if ($msg = parent::store()) { $this->_error['store'] = $msg; } else { $stored = true; } } if (0 == $this->{$this->_tbl_key} && $this->_perms->checkModuleItem($this->_tbl_module, 'add')) { $this->file_owner = $this->_AppUI->user_id; $q = $this->_getQuery(); $q->clear(); $q->addTable('files'); if (!$this->file_version_id) { $q->addQuery('file_version_id'); $q->addOrder('file_version_id DESC'); $q->setLimit(1); $latest_file_version = $q->loadResult(); $this->file_version_id = $latest_file_version + 1; } else { $q->addUpdate('file_checkout', ''); $q->addWhere('file_version_id = ' . (int) $this->file_version_id); $q->exec(); } $q->clear(); $this->file_date = $q->dbfnNowWithTZ(); if ($msg = parent::store()) { $this->_error['store'] = $msg; } else { $stored = true; } } return $stored; }
public function store() { $stored = false; $this->_error = $this->check(); if (count($this->_error)) { return $this->_error; } $q = $this->_getQuery(); //TODO: this is an oddball permissions object where the module doesn't determine the access.. if ($this->{$this->_tbl_key} && $this->_perms->checkModuleItem('forums', 'edit', $this->{$this->_tbl_module})) { $q->setDelete('forum_visits'); $q->addWhere('visit_message = ' . (int) $this->message_id); $q->exec(); if ($msg = parent::store()) { $this->_error['store'] = $msg; } else { $stored = true; } } if (0 == $this->{$this->_tbl_key} && $this->_perms->checkModuleItem('forums', 'add')) { $this->message_date = $q->dbfnNowWithTZ(); if ($msg = parent::store()) { $this->_error['store'] = $msg; } else { $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->overrideDatabase($this->_query); $forum->load(null, $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(); $this->sendWatchMail(false); $stored = true; } } return $stored; }
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 function store(CAppUI $AppUI) { $perms = $AppUI->acl(); $stored = false; /* * 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... */ if ($this->holiday_id && $perms->checkModuleItem('holiday', 'edit', $this->holiday_id)) { if ($msg = parent::store()) { return $msg; } $stored = true; } if (0 == $this->holiday_id && $perms->checkModuleItem('holiday', 'add')) { if ($msg = parent::store()) { return $msg; } $stored = true; } return $stored; }
/** * @todo Parent store could be partially used */ public function store($unused = null) { $stored = false; if ($this->task_start_date == '') { $this->task_start_date = '0000-00-00 00:00:00'; } if ($this->task_end_date == '') { $this->task_end_date = '0000-00-00 00:00:00'; } if ($this->{$this->_tbl_key} && $this->canEdit()) { // Load and globalize the old, not yet updated task object // e.g. we need some info later to calculate the shifting time for depending tasks // see function update_dep_dates global $oTsk; $oTsk = new CTask(); $oTsk->overrideDatabase($this->_query); $oTsk->load($this->task_id); if (!parent::store()) { $this->_error['store'] = "There was an error in storing this object."; return false; } // if task_status changed, then update subtasks if ($this->task_status != $oTsk->task_status) { $this->updateSubTasksStatus($this->task_status); } $stored = parent::store(); } if (0 == $this->{$this->_tbl_key} && $this->canCreate()) { $stored = parent::store(); } return $stored; }
public function store(w2p_Core_CAppUI $AppUI) { $perms = $AppUI->acl(); $stored = false; $errorMsgArray = $this->check(); if (count($errorMsgArray) > 0) { return $errorMsgArray; } $q = new w2p_Database_Query(); $this->w2PTrimAll(); if ($this->planner_id && $perms->checkModuleItem('planner', 'edit', $this->planner_id)) { if ($msg = parent::store()) { return $msg; } $stored = true; } if (0 == $this->planner_id && $perms->checkModuleItem('planner', 'add')) { if ($msg = parent::store()) { return $msg; } $stored = true; } return $stored; }
public function store(CAppUI $AppUI) { $perms = $AppUI->acl(); $stored = false; $this->_error = $this->check(); if (count($this->_error)) { return $this->_error; } $this->company_id = (int) $this->company_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... */ if ($this->company_id && canEdit('companies', $this->company_id)) { if ($msg = parent::store()) { return $msg; } $stored = true; } if (0 == $this->company_id && canAdd('companies')) { if ($msg = parent::store()) { return $msg; } $stored = true; } if ($stored) { $custom_fields = new w2p_Core_CustomFields('companies', 'addedit', $this->company_id, 'edit'); $custom_fields->bind($_POST); $sql = $custom_fields->store($this->company_id); // Store Custom Fields } return $stored; }
public function store() { $stored = false; if (strpos($this->link_url, ':') === false && strpos($this->link_url, "//") === false) { $this->link_url = 'http://' . $this->link_url; } $this->_error = $this->check(); if (count($this->_error)) { return $this->_error; } /* * 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 = $this->_getQuery(); $this->link_date = $q->dbfnNowWithTZ(); if ($this->{$this->_tbl_key} && $this->_perms->checkModuleItem($this->_tbl_module, 'edit', $this->{$this->_tbl_key})) { if ($msg = parent::store()) { $this->_error['store'] = $msg; } else { $stored = true; } } if (0 == $this->{$this->_tbl_key} && $this->_perms->checkModuleItem($this->_tbl_module, 'add')) { if ($msg = parent::store()) { $this->_error['store'] = $msg; } else { $stored = true; } } return $stored; }
public function store(CAppUI $AppUI) { $perms = $AppUI->acl(); $stored = false; if (!$this->event_recurs) { $this->event_times_recuring = 0; } else { //If the event recurs then set the end date day to be equal to the start date day and keep the hour:minute of the end date //so that the event starts recurring from the start day onwards n times after the start date for the period given //Meaning: The event end date day is useless as far as recurring events are concerned. $start_date = new w2p_Utilities_Date($this->event_start_date); $end_date = new w2p_Utilities_Date($this->event_end_date); $hour = $end_date->getHour(); $minute = $end_date->getMinute(); $end_date->setDate($start_date->getDate()); $end_date->setHour($hour); $end_date->setMinute($minute); $this->event_end_date = $end_date->format(FMT_DATETIME_MYSQL); } // ensure changes to check boxes and select lists are honoured $this->event_private = (int) $this->event_private; $this->event_type = (int) $this->event_type; $this->event_cwd = (int) $this->event_cwd; $this->_error = $this->check(); if (count($this->_error)) { return $this->_error; } $this->event_start_date = $AppUI->convertToSystemTZ($this->event_start_date); $this->event_end_date = $AppUI->convertToSystemTZ($this->event_end_date); /* * 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... */ if ($this->event_id && $perms->checkModuleItem('events', 'edit', $this->event_id)) { if ($msg = parent::store()) { return $msg; } $stored = true; } if (0 == $this->event_id && $perms->checkModuleItem('events', 'add')) { if ($msg = parent::store()) { return $msg; } $stored = true; } if ($stored) { // TODO: I *really* don't like using the POST inside here.. $this->updateAssigned(explode(',', $_POST['event_assigned'])); $custom_fields = new w2p_Core_CustomFields('calendar', 'addedit', $this->event_id, 'edit'); $custom_fields->bind($_POST); $sql = $custom_fields->store($this->event_id); // Store Custom Fields } return $stored; }
public function store() { $stored = false; $q = $this->_getQuery(); if (!$this->event_recurs) { $this->event_times_recuring = 0; } else { //If the event recurs then set the end date day to be equal to the start date day and keep the hour:minute of the end date //so that the event starts recurring from the start day onwards n times after the start date for the period given //Meaning: The event end date day is useless as far as recurring events are concerned. $start_date = new w2p_Utilities_Date($this->event_start_date); $end_date = new w2p_Utilities_Date($this->event_end_date); $hour = $end_date->getHour(); $minute = $end_date->getMinute(); $end_date->setDate($start_date->getDate()); $end_date->setHour($hour); $end_date->setMinute($minute); $this->event_end_date = $end_date->format(FMT_DATETIME_MYSQL); } // ensure changes to check boxes and select lists are honoured $this->event_private = (int) $this->event_private; $this->event_type = (int) $this->event_type; $this->event_cwd = (int) $this->event_cwd; $this->event_start_date = $this->_AppUI->convertToSystemTZ($this->event_start_date); $this->event_end_date = $this->_AppUI->convertToSystemTZ($this->event_end_date); /* * 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... */ if ($this->{$this->_tbl_key} && $this->canEdit()) { $this->event_updated = $q->dbfnNowWithTZ(); $stored = parent::store(); } if (0 == $this->{$this->_tbl_key} && $this->canCreate()) { $this->event_created = $q->dbfnNowWithTZ(); $this->event_updated = $this->event_created; $stored = parent::store(); } return $stored; }
/** * @todo Parent store could be partially used */ public function store(CAppUI $AppUI = null) { global $AppUI; $perms = $AppUI->acl(); $stored = false; $this->w2PTrimAll(); if (!$this->task_owner) { $this->task_owner = $AppUI->user_id; } $importing_tasks = false; $this->_error = $this->check(); if (count($this->_error)) { return $this->_error; } $this->task_target_budget = filterCurrency($this->task_target_budget); $q = new w2p_Database_Query(); $this->task_updated = $q->dbfnNowWithTZ(); if ($this->task_id && $perms->checkModuleItem('tasks', 'edit', $this->task_id)) { // Load and globalize the old, not yet updated task object // e.g. we need some info later to calculate the shifting time for depending tasks // see function update_dep_dates global $oTsk; $oTsk = new CTask(); $oTsk->load($this->task_id); if ($this->task_start_date == '') { $this->task_start_date = '0000-00-00 00:00:00'; } if ($this->task_end_date == '') { $this->task_end_date = '0000-00-00 00:00:00'; } if ($msg = parent::store()) { return $msg; } // if task_status changed, then update subtasks if ($this->task_status != $oTsk->task_status) { $this->updateSubTasksStatus($this->task_status); } // Moving this task to another project? if ($this->task_project != $oTsk->task_project) { $this->updateSubTasksProject($this->task_project); } if ($this->task_dynamic == 1) { $this->updateDynamics(true); } if ($msg = parent::store()) { return $msg; } // Milestone or task end date, or dynamic status has changed, // shift the dates of the tasks that depend on this task if ($this->task_end_date != $oTsk->task_end_date || $this->task_dynamic != $oTsk->task_dynamic || $this->task_milestone == '1') { $this->shiftDependentTasks(); } if (!$this->task_parent) { $q->addTable('tasks'); $q->addUpdate('task_parent', $this->task_id); $q->addUpdate('task_updated', "'" . $q->dbfnNowWithTZ() . "'", false, true); $q->addWhere('task_id = ' . (int) $this->task_id); $q->exec(); $q->clear(); } $stored = true; } if (0 == $this->task_id && $perms->checkModuleItem('tasks', 'add')) { $this->task_created = $q->dbfnNowWithTZ(); if ($this->task_start_date == '') { $this->task_start_date = '0000-00-00 00:00:00'; } if ($this->task_end_date == '') { $this->task_end_date = '0000-00-00 00:00:00'; } if ($msg = parent::store()) { return $msg; } $q->clear(); if (!$this->task_parent) { $q->addTable('tasks'); $q->addUpdate('task_parent', $this->task_id); $q->addUpdate('task_updated', "'" . $q->dbfnNowWithTZ() . "'", false, true); $q->addWhere('task_id = ' . (int) $this->task_id); $q->exec(); $q->clear(); } else { // importing tasks do not update dynamics $importing_tasks = true; } $stored = true; } $last_task_data = $this->getLastTaskData($this->task_project); CProject::updateTaskCache($this->task_project, $last_task_data['task_id'], $last_task_data['last_date'], $this->getTaskCount($this->task_project)); $this->pushDependencies($this->task_id, $this->task_end_date); //split out related departments and store them seperatly. $q->setDelete('task_departments'); $q->addWhere('task_id=' . (int) $this->task_id); $q->exec(); $q->clear(); if (!empty($this->task_departments)) { $departments = explode(',', $this->task_departments); foreach ($departments as $department) { $q->addTable('task_departments'); $q->addInsert('task_id', $this->task_id); $q->addInsert('department_id', $department); $q->exec(); $q->clear(); } } //split out related contacts and store them seperatly. $q->setDelete('task_contacts'); $q->addWhere('task_id=' . (int) $this->task_id); $q->exec(); $q->clear(); if ($this->task_contacts) { foreach ($this->task_contacts as $contact) { if ($contact) { $q->addTable('task_contacts'); $q->addInsert('task_id', $this->task_id); $q->addInsert('contact_id', $contact); $q->exec(); $q->clear(); } } } // if is child update parent task if ($this->task_parent && $this->task_parent != $this->task_id) { if (!$importing_tasks) { $this->updateDynamics(true); } $pTask = new CTask(); $pTask->load($this->task_parent); $pTask->updateDynamics(); if ($oTsk->task_parent != $this->task_parent) { $old_parent = new CTask(); $old_parent->load($oTsk->task_parent); $old_parent->updateDynamics(); } } // update dependencies if (!empty($this->task_id)) { $this->updateDependencies($this->getDependencies(), $this->task_parent); } return $stored; }
/** * Stores the current task log in the database updating the task_log_updated * field appropriately. Then updates total hours worked cache on task. * * @return void * * @access public */ public function store(CAppUI $AppUI = null) { global $AppUI; $perms = $AppUI->acl(); $this->_error = $this->check(); if (count($this->_error)) { return $this->_error; } $q = new w2p_Database_Query(); $this->task_log_updated = $q->dbfnNowWithTZ(); if ($this->task_log_date) { $date = new w2p_Utilities_Date($this->task_log_date); $this->task_log_date = $date->format(FMT_DATETIME_MYSQL); } $dot = strpos($this->task_log_hours, ':'); if ($dot > 0) { $log_duration_minutes = sprintf('%.3f', substr($this->task_log_hours, $dot + 1) / 60.0); $this->task_log_hours = floor($this->task_log_hours) + $log_duration_minutes; } $this->task_log_hours = $this->task_log_hours; $this->task_log_costcode = cleanText($this->task_log_costcode); if ($this->task_log_id && $perms->checkModuleItem('task_log', 'edit', $this->task_log_id)) { if ($msg = parent::store()) { return $msg; } $stored = true; $this->updateHoursWorked($this->task_log_task); } if (0 == $this->task_log_id && $perms->checkModuleItem('task_log', 'add')) { $this->task_log_created = $q->dbfnNowWithTZ(); if ($msg = parent::store()) { return $msg; } $stored = true; $this->updateHoursWorked($this->task_log_task); } return $stored; }
/** * Stores the current task log in the database updating the task_log_updated * field appropriately. Then updates total hours worked cache on task. * * @return void * * @access public */ public function store() { $this->_error = $this->check(); if (count($this->_error)) { return $this->_error; } $q = $this->_getQuery(); $this->task_log_updated = $q->dbfnNowWithTZ(); if ($this->task_log_date) { $date = new w2p_Utilities_Date($this->task_log_date); $this->task_log_date = $date->format(FMT_DATETIME_MYSQL); } $dot = strpos($this->task_log_hours, ':'); if ($dot > 0) { $log_duration_minutes = sprintf('%.3f', substr($this->task_log_hours, $dot + 1) / 60.0); $this->task_log_hours = floor($this->task_log_hours) + $log_duration_minutes; } $this->task_log_hours = $this->task_log_hours; $this->task_log_costcode = cleanText($this->task_log_costcode); if ($this->{$this->_tbl_key} && $this->_perms->checkModuleItem($this->_tbl_module, 'edit', $this->{$this->_tbl_key})) { if ($msg = parent::store()) { $this->_error['store-check'] = $msg; } else { $stored = true; $this->updateTaskSummary($this->_AppUI, $this->task_log_task); } } if (0 == $this->{$this->_tbl_key} && $this->_perms->checkModuleItem($this->_tbl_module, 'add')) { $this->task_log_created = $q->dbfnNowWithTZ(); if ($msg = parent::store()) { $this->_error['store-check'] = $msg; } else { $stored = true; $this->updateTaskSummary(null, $this->task_log_task); } } return $stored; }
public function store(CAppUI $AppUI) { $perms = $AppUI->acl(); $stored = false; if (strpos($this->link_url, ':') === false && strpos($this->link_url, "//") === false) { $this->link_url = 'http://' . $this->link_url; } $this->_error = $this->check(); if (count($this->_error)) { return $this->_error; } /* * 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->link_date = $q->dbfnNowWithTZ(); if ($this->link_id && $perms->checkModuleItem('links', 'edit', $this->link_id)) { if ($msg = parent::store()) { return $msg; } $stored = true; } if (0 == $this->link_id && $perms->checkModuleItem('links', 'add')) { if ($msg = parent::store()) { return $msg; } $stored = true; } return $stored; }
public function store(CAppUI $AppUI) { $perms = $AppUI->acl(); $stored = false; $this->_error = $this->check(); if (count($this->_error)) { return $this->_error; } if ($this->forum_id && $perms->checkModuleItem('forums', 'edit', $this->forum_id)) { if ($msg = parent::store()) { return $msg; } $stored = true; } if (0 == $this->forum_id && $perms->checkModuleItem('forums', 'add')) { $this->forum_create_date = $AppUI->convertToSystemTZ($this->forum_create_date); if ($msg = parent::store()) { return $msg; } $stored = true; } return $stored; }
public function store(CAppUI $AppUI) { $perms = $AppUI->acl(); $stored = false; $this->file_folder_id = (int) $this->file_folder_id; $this->file_folder_parent = (int) $this->file_folder_parent; $this->_error = $this->check(); if (count($this->_error)) { return $this->_error; } /* * 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... */ if ($this->file_folder_id && $perms->checkModuleItem('files', 'edit')) { if ($msg = parent::store()) { return $msg; } $stored = true; } if (0 == $this->file_folder_id && $perms->checkModuleItem('files', 'add')) { if ($msg = parent::store()) { return $msg; } $stored = true; } return $stored; }
public function store(CAppUI $AppUI = null) { global $AppUI; $perms = $AppUI->acl(); $stored = false; $this->_error = $this->check(); if (count($this->_error)) { return $this->_error; } if ($this->dept_id && $perms->checkModuleItem('departments', 'edit', $this->dept_id)) { if ($msg = parent::store()) { return $msg; } $stored = true; } if (0 == $this->dept_id && $perms->checkModuleItem('departments', 'add')) { if ($msg = parent::store()) { return $msg; } $stored = true; } return $stored; }
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 = $this->_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->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 function store() { $stored = false; $this->_error = $this->check(); if (count($this->_error)) { return $this->_error; } if ($this->{$this->_tbl_key} && $this->_perms->checkModuleItem($this->_tbl_module, 'edit', $this->{$this->_tbl_key})) { if ($msg = parent::store()) { $this->_error['store'] = $msg; } else { $stored = true; } } if (0 == $this->{$this->_tbl_key} && $this->_perms->checkModuleItem($this->_tbl_module, 'add')) { $this->forum_create_date = $this->_AppUI->convertToSystemTZ($this->forum_create_date); if ($msg = parent::store()) { $this->_error['store'] = $msg; } else { $stored = true; } } return $stored; }
public function store(CAppUI $AppUI = null) { global $AppUI; $perms = $AppUI->acl(); $stored = false; $this->_error = array(); $q = $this->_query; $q->addQuery('billingcode_id'); $q->addTable('billingcode'); $q->addWhere('billingcode_name = \'' . $this->billingcode_name . '\''); $q->addWhere('company_id = ' . (int) $this->company_id); $found_id = $q->loadResult(); $q->clear(); if ($found_id && $found_id != $this->_billingcode_id) { return 'Billing Code::code already exists'; } else { if ($perms->checkModuleItem('system', 'edit')) { if ($msg = parent::store()) { return $msg; } $stored = true; } } return $stored; }
/** * @todo TODO: I *really* hate how we have to do the store() twice when we * create the project.. it's all because the stupid project_original_parent * has to equal its own project_id if this is a root project. Ugh. */ protected function hook_postCreate() { if (0 == $this->project_parent || 0 == $this->project_original_parent) { $this->project_parent = $this->project_id; $this->project_original_parent = $this->project_id; parent::store(); } parent::hook_postCreate(); }
public function store(CAppUI $AppUI = null) { global $AppUI; $perms = $AppUI->acl(); $this->contact_company = (int) $this->contact_company; $this->contact_department = (int) $this->contact_department; $this->contact_owner = (int) $this->contact_owner; $this->contact_private = (int) $this->contact_private; $this->contact_first_name = $this->contact_first_name == null ? '' : $this->contact_first_name; $this->contact_last_name = $this->contact_last_name == null ? '' : $this->contact_last_name; $this->contact_order_by = $this->contact_order_by == null ? '' : $this->contact_order_by; $this->contact_display_name = $this->contact_display_name == null ? '' : $this->contact_display_name; $this->contact_birthday = $this->contact_birthday == '' ? null : $this->contact_birthday; /* * This validates that any Contact saved will have a Display Name as * required by various dropdowns, etc throughout the system. This is * mostly required when Contacts are generated via programatic methods and * not through the add/edit UI. */ if (mb_strlen($this->contact_order_by) <= 1) { $this->contact_order_by = mb_trim($this->contact_first_name . ' ' . $this->contact_last_name); } if (mb_strlen($this->contact_display_name) <= 1) { $this->contact_display_name = mb_trim($this->contact_first_name . ' ' . $this->contact_last_name); } $this->_error = $this->check(); if (count($this->_error)) { return $this->_error; } $q = $this->_query; $this->contact_lastupdate = $q->dbfnNowWithTZ(); /* * 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... */ if ($this->contact_id) { // && $perms->checkModuleItem('contacts', 'edit', $this->contact_id)) { if ($msg = parent::store()) { return $msg; } $stored = true; } if (0 == $this->contact_id) { // && $perms->checkModuleItem('contacts', 'add')) { if ($msg = parent::store()) { return $msg; } $stored = true; } if ($stored) { $custom_fields = new w2p_Core_CustomFields('contacts', 'addedit', $this->contact_id, 'edit'); $custom_fields->bind($_POST); $sql = $custom_fields->store($this->contact_id); // Store Custom Fields } if ($stored) { $foto = W2P_BASE_DIR . '/fotos/' . $this->contact_id . '.jpg'; $foto_temp = W2P_BASE_DIR . '/fotos/temp.jpg'; if (file_exists($foto) && file_exists($foto_temp)) { unlink($foto); } if (file_exists($foto_temp)) { rename($foto_temp, $foto); if (file_exists($foto_temp)) { unlink($foto_temp); } } } /* * TODO: I don't like using the $_POST in here.. */ if ($stored) { $methods = array(); if (!empty($_POST['contact_methods'])) { foreach ($_POST['contact_methods']['field'] as $key => $field) { $methods[$field] = $_POST['contact_methods']['value'][$key]; } } $this->setContactMethods($methods); } return $stored; }
public function store(CAppUI $AppUI = null) { global $AppUI; $perms = $AppUI->acl(); $stored = false; $this->_error = $this->check(); if (count($this->_error)) { return false; } if ($this->user_id && $perms->checkModuleItem('users', 'edit', $this->user_id)) { $perm_func = 'updateLogin'; $tmpUser = new CUser(); $tmpUser->load($this->user_id); if ('' == trim($this->user_password)) { $this->user_password = $tmpUser->user_password; } elseif ($tmpUser->user_password != md5($this->user_password)) { $this->user_password = md5($this->user_password); } else { $this->user_password = $tmpUser->user_password; } if ($msg = parent::store()) { $this->_error = $msg; return false; } $stored = true; } if (0 == $this->user_id && $perms->checkModuleItem('users', 'add')) { $perm_func = 'addLogin'; $this->user_password = md5($this->user_password); if ($msg = parent::store()) { $this->_error = $msg; return false; } $stored = true; } if ($stored) { $perms->{$perm_func}($this->user_id, $this->user_username); $q = $this->_query; //Lets check if the user has allready default users preferences set, if not insert the default ones $q->addTable('user_preferences', 'upr'); $q->addWhere('upr.pref_user = '******'user_preferences', 'dup'); $q->addWhere('dup.pref_user = 0'); $w2prefs = $q->loadList(); $q->clear(); foreach ($w2prefs as $w2prefskey => $w2prefsvalue) { $q->addTable('user_preferences', 'up'); $q->addInsert('pref_user', $this->user_id); $q->addInsert('pref_name', $w2prefsvalue['pref_name']); $q->addInsert('pref_value', $w2prefsvalue['pref_value']); $q->exec(); $q->clear(); } } return $stored; } return $stored; }