public function __construct() { $this->_ci = get_instance(); // Codeigniter instance self::$instance = $this; // Instance of this class $this->_ci->load->driver('cache', array('adapter' => 'apc', 'backup' => 'file')); $this->_ci->load->helper('directory'); $this->_ci->load->helper('file'); // Set the plugins directory if not already set if (is_null($this->plugins_dir)) { $this->plugins_dir = FCPATH . "plugins/"; } $this->find_plugins(); // Find all plugins $this->get_activated_plugins(); // Get all activated plugins $this->get_plugin_infos(); // Gets information about all plugins and stores it $this->include_plugins(); // Include plugins self::$messages = ""; // Clear messages self::$errors = ""; // Clear errors }
static function init() { $base_hooks_dir = ROOT . "/hooks" ; if (is_dir($base_hooks_dir)) { $handle = opendir($base_hooks_dir); while ($file = readdir($handle)) { if (is_file("$base_hooks_dir/$file") && substr($file, -4) == '.php') { include_once "$base_hooks_dir/$file"; } } closedir($handle); } foreach ( Plugins::instance()->getActive() as $plugin ){ /* @var $plugin Plugin */ $plugin_hooks_dir = $plugin->getHooksPath(); if (is_dir($plugin_hooks_dir)) { $handle = opendir($plugin_hooks_dir); while ($file = readdir($handle)) { if (is_file("$plugin_hooks_dir/$file") && substr($file, -4) == '.php') { include_once "$plugin_hooks_dir/$file"; } } $plugin->getSystemName() ; closedir($handle); } } }
/** * Constructor * * @param mixed $params * @return Plugins */ public function __construct($params = array()) { $this->_ci = get_instance(); // Codeigniter instance self::$instance = $this; // Instance of this class $this->_ci->load->database(); $this->_ci->load->helper('directory'); $this->_ci->load->helper('file'); $this->_ci->load->helper('url'); // Set the plugins directory if passed via paramater if (array_key_exists('plugins_dir', $params)) { $this->set_plugin_dir($params['plugins_dir']); } else // else set to default value { $this->set_plugin_dir(FCPATH . "plugins"); } // Remove index.php string on the plugins directory if any $this->plugins_dir = str_replace("index.php", "", $this->plugins_dir); $this->find_plugins(); // Find all plugins $this->get_activated_plugins(); // Get all activated plugins $this->get_plugin_infos(); // Gets information about all plugins and stores it $this->include_plugins(); // Include plugins self::$messages = ""; // Clear messages self::$errors = ""; // Clear errors }
public function __construct($params = array()) { $this->_ci = get_instance(); // Codeigniter instance self::$instance = $this; // Instance of this class // Driver library only available on CI 2.0+ if (CI_VERSION >= 2.0) { $this->_ci->load->driver('cache', array('adapter' => 'apc', 'backup' => 'file')); } $this->_ci->load->database(); $this->_ci->load->helper('directory'); $this->_ci->load->helper('file'); // Set the plugins directory if passed via paramater if (array_key_exists('plugins_dir', $params)) { $this->set_plugin_dir($params['plugins_dir']); } else { $this->set_plugin_dir(FCPATH . "plugins/"); } // Remove index.php string on the plugins directory if any $this->plugins_dir = str_replace("index.php", "", $this->plugins_dir); $this->find_plugins(); // Find all plugins $this->get_activated_plugins(); // Get all activated plugins $this->get_plugin_infos(); // Gets information about all plugins and stores it $this->include_plugins(); // Include plugins self::$messages = ""; // Clear messages self::$errors = ""; // Clear errors }
public static function getInstance() { if (null === self::$instance) { self::$instance = new self(); } return self::$instance; }
/** * @return Plugin */ function getPlugin() { if (is_null($this->plugin) ) { if ($pid = $this->getPluginId()){ $this->plugin = Plugins::instance()->findById($pid); } } return $this->plugin ; }
function delete_mails_from_server() { if (Plugins::instance()->isActivePlugin('mail')) { try { _log("Checking mail accounts to delete mails from server..."); $count = MailUtilities::deleteMailsFromServerAllAccounts(); _log("Deleted $count mails from server..."); } catch (Exception $e) { _log("Error deleting mails from server: " . $e->getMessage()); } } }
public function action_deactivate() { $plugin = $this->request->param('plugin'); $msg = array('title' => 'Deactivation'); if (array_key_exists($plugin, Plugins::$plugins_pool)) { $plug = Plugins::instance()->load_plugin($plugin); if (Plugins::$manager->is_active($plugin) == false) { $msg['class'] = 'alert-warning'; $msg['content'] = $plug->info['name'] . ' is not active'; } else { if (Plugins::$manager->deactivate($plugin)) { $msg['class'] = 'alert-success'; $msg['content'] = $plug->info['name'] . ' was successfully deactivated.'; } else { $msg['class'] = 'alert-warning'; $msg['content'] = 'There was an error deactivating ' . $plug->info['name']; } } } else { $msg['class'] = 'alert-danger'; $msg['content'] = $plugin . ' does not seem to exist.'; } $this->action_index($msg); }
/** * Return manager instance * * @access protected * @param void * @return Plugins */ function manager() { if (! ($this->manager instanceof Plugins)) $this->manager = Plugins::instance (); return $this->manager; } // manager
$icons[] = array( 'ico' => 'ico-large-upgrade', 'url' => get_url('administration', 'upgrade'), 'name' => lang('upgrade'), 'extra' => '', ); }*/ if (!defined('ALLOW_CONFIGURING_CRON') || ALLOW_CONFIGURING_CRON) { $icons[] = array('ico' => 'ico-large-cron', 'url' => get_url('administration', 'cron_events'), 'name' => lang('cron events'), 'extra' => ''); } $icons[] = array('ico' => 'ico-large-tabs', 'url' => get_url('administration', 'tabs'), 'name' => lang('tabs'), 'extra' => ''); } if (can_manage_dimension_members(logged_user())) { $icons[] = array('ico' => 'ico-large-workspace', 'url' => get_url('administration', 'edit_members'), 'name' => lang('dimensions'), 'extra' => ''); } if (can_manage_security(logged_user()) && Plugins::instance()->isActivePlugin('income')) { $icons[] = array('ico' => 'ico-large-invoice', 'url' => get_url('income', 'administration'), 'name' => lang('income'), 'extra' => ''); } if (defined("PLUGIN_MANAGER") && PLUGIN_MANAGER && can_manage_plugins(logged_user())) { $icons[] = array('ico' => 'ico-large-plugins', 'url' => get_url('plugin', 'index'), 'name' => lang('plugins'), 'extra' => ''); } Hook::fire('render_administration_icons', null, $icons); if (count($icons > 0)) { } ?> <div class="coInputHeader"> <div class="coInputHeaderUpperRow"> <div class="coInputTitle"> <?php echo lang('administration');
/** * Edit task * * @access public * @param void * @return null */ function edit_task() { if (logged_user()->isGuest()) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $this->setTemplate('add_task'); $task = ProjectTasks::findById(get_id()); if (!$task instanceof ProjectTask) { flash_error(lang('task list dnx')); ajx_current("empty"); return; } // if if (!$task->canEdit(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if if (array_var($_GET, 'replace')) { ajx_replace(true); } $task_data = array_var($_POST, 'task'); $time_estimate = array_var($_POST, 'hours', 0) * 60 + array_var($_POST, 'minutes', 0); if ($time_estimate > 0) { $estimatedTime = $time_estimate; } else { $estimatedTime = $task->getTimeEstimate(); } if (!is_array($task_data)) { $this->getRepeatOptions($task, $occ, $rsel1, $rsel2, $rsel3, $rnum, $rend, $rjump); $dd = $task->getDueDate() instanceof DateTimeValue ? $task->getDueDate()->advance(logged_user()->getTimezone() * 3600, false) : null; $sd = $task->getStartDate() instanceof DateTimeValue ? $task->getStartDate()->advance(logged_user()->getTimezone() * 3600, false) : null; $post_dd = null; if (array_var($_POST, 'task_due_date')) { $post_dd = getDateValue(array_var($_POST, 'task_due_date')); if ($post_dd instanceof DateTimeValue) { $duetime = getTimeValue(array_var($_POST, 'task_due_time')); if (is_array($duetime)) { $post_dd->setHour(array_var($duetime, 'hours')); $post_dd->setMinute(array_var($duetime, 'mins')); $post_dd->advance(logged_user()->getTimezone() * 3600, false); } } } $post_st = null; if (array_var($_POST, 'task_start_date')) { $post_st = getDateValue(array_var($_POST, 'task_start_date')); if ($post_st instanceof DateTimeValue) { $starttime = getTimeValue(array_var($_POST, 'task_start_time')); if (is_array($starttime)) { $post_st->setHour(array_var($starttime, 'hours')); $post_st->setMinute(array_var($starttime, 'mins')); $post_st->advance(logged_user()->getTimezone() * 3600, false); } } } $task_data = array('name' => array_var($_POST, 'name', $task->getObjectName()), 'text' => array_var($_POST, 'text', $task->getText()), 'milestone_id' => array_var($_POST, 'milestone_id', $task->getMilestoneId()), 'due_date' => getDateValue($post_dd, $dd), 'start_date' => getDateValue($post_st, $sd), 'parent_id' => $task->getParentId(), 'assigned_to_contact_id' => array_var($_POST, 'assigned_to_contact_id', $task->getAssignedToContactId()), 'priority' => array_var($_POST, 'priority', $task->getPriority()), 'send_notification' => array_var($_POST, 'notify') == 'true', 'time_estimate' => $estimatedTime, 'percent_completed' => $task->getPercentCompleted(), 'forever' => $task->getRepeatForever(), 'rend' => $rend, 'rnum' => $rnum, 'rjump' => $rjump, 'rsel1' => $rsel1, 'rsel2' => $rsel2, 'rsel3' => $rsel3, 'occ' => $occ, 'repeat_by' => $task->getRepeatBy(), 'object_subtype' => array_var($_POST, "object_subtype", $task->getObjectSubtype() != 0 ? $task->getObjectSubtype() : config_option('default task co type')), 'type_content' => $task->getTypeContent(), 'multi_assignment' => $task->getColumnValue('multi_assignment', 0)); // array } // if //I find all those related to the task to find out if the original $task_related = ProjectTasks::findByRelated($task->getObjectId()); if (!$task_related) { //is not the original as the original look plus other related if ($task->getOriginalTaskId() != "0") { $task_related = ProjectTasks::findByTaskAndRelated($task->getObjectId(), $task->getOriginalTaskId()); } } if ($task_related) { $pending_id = 0; foreach ($task_related as $t_rel) { if ($task->getStartDate() <= $t_rel->getStartDate() && $task->getDueDate() <= $t_rel->getDueDate() && !$t_rel->isCompleted()) { $pending_id = $t_rel->getId(); break; } } tpl_assign('pending_task_id', $pending_id); tpl_assign('task_related', true); } else { tpl_assign('pending_task_id', 0); tpl_assign('task_related', false); } tpl_assign('task', $task); tpl_assign('task_data', $task_data); if (is_array(array_var($_POST, 'task'))) { $send_edit = false; if ($task->getAssignedToContactId() == array_var($task_data, 'assigned_to_contact_id')) { $send_edit = true; } $old_owner = $task->getAssignedTo(); if (array_var($task_data, 'parent_id') == $task->getId()) { flash_error(lang("task own parent error")); ajx_current("empty"); return; } $task_data['due_date'] = getDateValue(array_var($_POST, 'task_due_date')); $task_data['start_date'] = getDateValue(array_var($_POST, 'task_start_date')); if ($task_data['due_date'] instanceof DateTimeValue) { $duetime = getTimeValue(array_var($_POST, 'task_due_time')); if (is_array($duetime)) { $task_data['due_date']->setHour(array_var($duetime, 'hours')); $task_data['due_date']->setMinute(array_var($duetime, 'mins')); } $task_data['due_date']->advance(logged_user()->getTimezone() * -3600); $task_data['use_due_time'] = is_array($duetime); } if ($task_data['start_date'] instanceof DateTimeValue) { $starttime = getTimeValue(array_var($_POST, 'task_start_time')); if (is_array($starttime)) { $task_data['start_date']->setHour(array_var($starttime, 'hours')); $task_data['start_date']->setMinute(array_var($starttime, 'mins')); } $task_data['start_date']->advance(logged_user()->getTimezone() * -3600); $task_data['use_start_time'] = is_array($starttime); } try { $err_msg = $this->setRepeatOptions($task_data); if ($err_msg) { flash_error($err_msg); ajx_current("empty"); return; } if (!isset($task_data['parent_id'])) { $task_data['parent_id'] = 0; } $member_ids = json_decode(array_var($_POST, 'members')); $was_template = $task->getIsTemplate(); if (config_option("wysiwyg_tasks")) { $task_data['type_content'] = "html"; $task_data['text'] = preg_replace("/[\n|\r|\n\r]/", '', array_var($task_data, 'text')); } else { $task_data['type_content'] = "text"; } $task->setFromAttributes($task_data); $task->setIsTemplate($was_template); // is_template value must not be changed from ui $totalMinutes = array_var($task_data, 'time_estimate_hours') * 60 + array_var($task_data, 'time_estimate_minutes'); $task->setTimeEstimate($totalMinutes); if ($task->getParentId() > 0 && $task->hasChild($task->getParentId())) { flash_error(lang('task child of child error')); ajx_current("empty"); return; } DB::beginWork(); $task->save(); $this->calculate_time_estimate($task, array_var($task_data, "percent_completed")); // dependencies if (config_option('use tasks dependencies')) { $previous_tasks = array_var($task_data, 'previous'); if (is_array($previous_tasks)) { foreach ($previous_tasks as $ptask) { if ($ptask == $task->getId()) { continue; } $dep = ProjectTaskDependencies::findById(array('previous_task_id' => $ptask, 'task_id' => $task->getId())); if (!$dep instanceof ProjectTaskDependency) { $dep = new ProjectTaskDependency(); $dep->setPreviousTaskId($ptask); $dep->setTaskId($task->getId()); $dep->save(); } } $saved_ptasks = ProjectTaskDependencies::findAll(array('conditions' => 'task_id = ' . $task->getId())); foreach ($saved_ptasks as $pdep) { if (!in_array($pdep->getPreviousTaskId(), $previous_tasks)) { $pdep->delete(); } } } else { ProjectTaskDependencies::delete('task_id = ' . $task->getId()); } } // Add assigned user to the subscibers list if ($task->getAssignedToContactId() > 0 && Contacts::instance()->findById($task->getAssignedToContactId())) { if (!isset($_POST['subscribers'])) { $_POST['subscribers'] = array(); } $_POST['subscribers']['user_' . $task->getAssignedToContactId()] = 'checked'; } $object_controller = new ObjectController(); $object_controller->add_to_members($task, $member_ids); $object_controller->add_subscribers($task); $object_controller->link_to_new_object($task); $object_controller->add_custom_properties($task); $object_controller->add_reminders($task); // apply values to subtasks $assigned_to = $task->getAssignedToContactId(); $subtasks = $task->getAllSubTasks(); $milestone_id = $task->getMilestoneId(); $apply_ms = array_var($task_data, 'apply_milestone_subtasks') == "checked"; $apply_at = array_var($task_data, 'apply_assignee_subtasks', '') == "checked"; foreach ($subtasks as $sub) { $modified = false; //if ($apply_at || !($sub->getAssignedToContactId() > 0)) { if ($apply_at) { $sub->setAssignedToContactId($assigned_to); $modified = true; } if ($apply_ms) { $sub->setMilestoneId($milestone_id); $modified = true; } if ($modified) { $sub->save(); } } $task->resetIsRead(); $log_info = ''; if ($send_edit == true) { $log_info = $task->getAssignedToContactId(); } else { if ($send_edit == false) { $task->setAssignedBy(logged_user()); $task->save(); } } ApplicationLogs::createLog($task, ApplicationLogs::ACTION_EDIT, false, false, true, $log_info); if (config_option('repeating_task') == 1) { $opt_rep_day['saturday'] = false; $opt_rep_day['sunday'] = false; if (array_var($task_data, 'repeat_saturdays', false)) { $opt_rep_day['saturday'] = true; } if (array_var($task_data, 'repeat_sundays', false)) { $opt_rep_day['sunday'] = true; } $this->repetitive_task($task, $opt_rep_day); } if (isset($_POST['type_related'])) { if ($_POST['type_related'] == "all" || $_POST['type_related'] == "news") { $task_data['members'] = json_decode(array_var($_POST, 'members')); unset($task_data['due_date']); unset($task_data['use_due_time']); unset($task_data['start_date']); unset($task_data['use_start_time']); $this->repetitive_tasks_related($task, "edit", $_POST['type_related'], $task_data); } } if (config_option('multi_assignment') && Plugins::instance()->isActivePlugin('crpm')) { if (array_var($task_data, 'multi_assignment_aplly_change') == 'subtask') { $null = null; Hook::fire('edit_subtasks', $task, $null); } } DB::commit(); try { if (array_var($task_data, 'send_notification') == 'checked' && $send_edit == false) { $new_owner = $task->getAssignedTo(); if ($new_owner instanceof Contact) { Notifier::taskAssigned($task); } // if } // if } catch (Exception $e) { } // try flash_success(lang('success edit task list', $task->getObjectName())); ajx_current("back"); } catch (Exception $e) { DB::rollback(); flash_error($e->getMessage()); ajx_current("empty"); } // try } // if }
/** * Used for Drag & Drop, adds objects to a member * @author alvaro */ function add_objects_to_member() { $ids = json_decode(array_var($_POST, 'objects')); $mem_id = array_var($_POST, 'member'); if (!is_array($ids) || count($ids) == 0) { ajx_current("empty"); return; } try { DB::beginWork(); if ($mem_id) { $user_ids = array(); $member = Members::findById($mem_id); $objects = array(); $from = array(); foreach ($ids as $oid) { /* @var $obj ContentDataObject */ $obj = Objects::findObject($oid); if ($obj instanceof ContentDataObject && $obj->canAddToMember(logged_user(), $member, active_context())) { $dim_obj_type_content = DimensionObjectTypeContents::findOne(array('conditions' => array('`dimension_id`=? AND `dimension_object_type_id`=? AND `content_object_type_id`=?', $member->getDimensionId(), $member->getObjectTypeId(), $obj->getObjectTypeId()))); if (!$dim_obj_type_content instanceof DimensionObjectTypeContent) { continue; } if (!$dim_obj_type_content->getIsMultiple() || array_var($_POST, 'remove_prev')) { $db_res = DB::execute("SELECT group_concat(om.member_id) as old_members FROM " . TABLE_PREFIX . "object_members om INNER JOIN " . TABLE_PREFIX . "members m ON om.member_id=m.id WHERE m.dimension_id=" . $member->getDimensionId() . " AND om.object_id=" . $obj->getId()); $row = $db_res->fetchRow(); if (array_var($row, 'old_members') != "") { $from[$obj->getId()] = $row['old_members']; } // remove from previous members ObjectMembers::delete('`object_id` = ' . $obj->getId() . ' AND `member_id` IN (SELECT `m`.`id` FROM `' . TABLE_PREFIX . 'members` `m` WHERE `m`.`dimension_id` = ' . $member->getDimensionId() . ')'); } $obj->addToMembers(array($member)); $obj->addToSharingTable(); $objects[] = $obj; if (Plugins::instance()->isActivePlugin('mail') && $obj instanceof MailContent) { $conversation = MailContents::getMailsFromConversation($obj); foreach ($conversation as $conv_email) { if (array_var($_POST, 'attachment') && $conv_email->getHasAttachments()) { MailUtilities::parseMail($conv_email->getContent(), $decoded, $parsedEmail, $warnings); $classification_data = array(); for ($j = 0; $j < count(array_var($parsedEmail, "Attachments", array())); $j++) { $classification_data["att_" . $j] = true; } MailController::classifyFile($classification_data, $conv_email, $parsedEmail, array($member), array_var($_POST, 'remove_prev'), false); } } } // if object is contact ask to add default permissions in member if ($obj instanceof Contact && $obj->isUser() && can_manage_security(logged_user())) { $user_ids[] = $obj->getId(); } } else { throw new Exception(lang('you dont have permissions to classify object in member', $obj->getName(), $member->getName())); } } // if object is contact ask to add default permissions in member if (can_manage_security(logged_user()) && count($user_ids) > 0 && $member->getDimension()->getDefinesPermissions()) { evt_add('ask to assign default permissions', array('user_ids' => $user_ids, 'member' => array('id' => $member->getId(), 'name' => clean($member->getName())), '')); } Hook::fire('after_dragdrop_classify', $objects, $member); $display_name = $member->getName(); $lang_key = count($ids) > 1 ? 'objects moved to member success' : 'object moved to member success'; $log_datas = array(); $actions = array(); // add to application logs foreach ($objects as $obj) { $actions[$obj->getId()] = array_var($from, $obj->getId()) ? ApplicationLogs::ACTION_MOVE : ApplicationLogs::ACTION_COPY; $log_datas[$obj->getId()] = (array_var($from, $obj->getId()) ? "from:" . array_var($from, $obj->getId()) . ";" : "") . "to:" . $member->getId(); } } else { if ($dim_id = array_var($_POST, 'dimension')) { $dimension = Dimensions::getDimensionById($dim_id); $from = array(); foreach ($ids as $oid) { /* @var $obj ContentDataObject */ $obj = Objects::findObject($oid); if ($obj instanceof ContentDataObject) { $db_res = DB::execute("SELECT group_concat(om.member_id) as old_members FROM " . TABLE_PREFIX . "object_members om INNER JOIN " . TABLE_PREFIX . "members m ON om.member_id=m.id WHERE m.dimension_id=" . $dim_id . " AND om.object_id=" . $obj->getId()); $row = $db_res->fetchRow(); if (array_var($row, 'old_members') != "") { $from[$obj->getId()] = $row['old_members']; } // remove from previous members ObjectMembers::delete('`object_id` = ' . $obj->getId() . ' AND `member_id` IN ( SELECT `m`.`id` FROM `' . TABLE_PREFIX . 'members` `m` WHERE `m`.`dimension_id` = ' . $dim_id . ')'); } $obj->addToMembers(array()); $obj->addToSharingTable(); $objects[] = $obj; } $display_name = $dimension->getName(); $lang_key = count($ids) > 1 ? 'objects removed from' : 'object removed from'; $log_datas = array(); $actions = array(); // add to application logs foreach ($objects as $obj) { $actions[$obj->getId()] = array_var($from, $obj->getId()) ? ApplicationLogs::ACTION_MOVE : ApplicationLogs::ACTION_COPY; $log_datas[$obj->getId()] = array_var($from, $obj->getId()) ? "from:" . array_var($from, $obj->getId()) . ";" : ""; } } } DB::commit(); foreach ($objects as $object) { ApplicationLogs::instance()->createLog($object, $actions[$object->getId()], false, true, true, $log_datas[$object->getId()]); } flash_success(lang($lang_key, $display_name)); if (array_var($_POST, 'reload')) { ajx_current('reload'); } else { ajx_current('empty'); } } catch (Exception $e) { DB::rollback(); ajx_current("empty"); flash_error($e->getMessage()); } }
function mail_accounts() { if (!can_manage_security(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } if (Plugins::instance()->isActivePlugin('mail')) { //$my_accounts = MailAccounts::getMailAccountsByUser(logged_user()); $all_accounts = MailAccounts::findAll(); } //tpl_assign('my_accounts', $my_accounts); tpl_assign('all_accounts', $all_accounts); }
function enable_disable_dimensions() { ajx_current("empty"); if (!can_manage_configuration(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $dims = json_decode(array_var($_REQUEST, 'dims'), true); //check active dims $at_least_one_dim_enabled = false; foreach ($dims as $dim_id => $enabled) { if ($enabled == true) { $at_least_one_dim_enabled = true; break; } } if (!$at_least_one_dim_enabled) { flash_error(lang('at least one dimension must be selected')); ajx_current("empty"); return; } $root_dids = explode(",", user_config_option('root_dimensions', null, logged_user()->getId())); $update_root_dimensions = false; $enabled_dim_vals = array(); foreach ($dims as $dim_id => $enabled) { if ($enabled) { $enabled_dim_vals[] = $dim_id; if (!in_array($dim_id, $root_dids)) { $root_dids[] = $dim_id; $update_root_dimensions = true; } $dim = Dimensions::findById($dim_id); if (($dim->getCode() == 'workspaces' || $dim->getCode() == 'tags') && !Plugins::instance()->isActivePlugin('workspaces')) { $plugin = Plugins::instance()->findOne(array('conditions' => "name='workspaces'")); if ($plugin instanceof Plugin) { $plugin->activate(); } } else { if ($dim->getCode() == 'customer_project' && !Plugins::instance()->isActivePlugin('crpm')) { $plugin = Plugins::instance()->findOne(array('conditions' => "name='crpm'")); if ($plugin instanceof Plugin) { $plugin->activate(); } } } } } set_config_option('enabled_dimensions', implode(',', $enabled_dim_vals)); if ($update_root_dimensions) { set_user_config_option('root_dimensions', implode(',', $root_dids), logged_user()->getId()); } ajx_extra_data(array('ok' => '1')); }
/** * Return path of specific template * * @access public * @param string $template * @param string $controller_name * @return string */ static function getTemplatePath($template, $controller_name = null, $plugin = null ) { if ($plugin) { $template_path = ROOT."/plugins/$plugin/application/views/$controller_name/$template.php"; return $template_path; } if ($plugin = Plugins::instance()->getCurrent()){ //$template_path = ROOT."/plugins/$plugin/application/views/$controller_name/$template.php"; $template_path = $plugin->getViewPath()."$controller_name/$template.php"; if ( is_file($template_path) ) { return $template_path ; } } if($controller_name) { return APPLICATION_PATH . "/views/$controller_name/$template.php"; } else { return APPLICATION_PATH . "/views/$template.php"; } // if } // getTemplatePath
$object_subtypes_array[] = $ot->getArrayInfo(); } if (!isset($dependency_count)) $dependency_count = array(); ?> <script> og.noOfTasks = '<?php echo user_config_option('noOfTasks') ?>'; og.genid = '<?php echo $genid?>'; og.config.wysiwyg_tasks = '<?php echo config_option('wysiwyg_tasks') ? true : false ?>'; og.config.use_tasks_dependencies = '<?php echo config_option('use tasks dependencies') ? "1" : "0" ?>'; og.config.time_format_use_24 = '<?php echo user_config_option('time_format_use_24') ? ' - G:i' : ' - g:i A' ?>'; og.config.time_format_use_24_duetime = '<?php echo user_config_option('time_format_use_24') ? 'G:i' : 'g:i A' ?>'; og.config.work_day_start_time = '<?php echo strtotime(user_config_option('work_day_start_time')) ?>'; og.config.work_day_end_time = '<?php echo strtotime(user_config_option('work_day_end_time')) ?>'; og.config.multi_assignment = '<?php echo config_option('multi_assignment') && Plugins::instance()->isActivePlugin('crpm') ? '1' : '0' ?>'; og.config.use_milestones = <?php echo config_option('use_milestones') ? 'true' : 'false' ?>; </script> <div id="taskPanelHiddenFields"> <input type="hidden" id="hfProjectTemplates" value="<?php echo clean(str_replace('"',"'", str_replace("'", "\'", json_encode($project_templates_array)))) ?>"/> <input type="hidden" id="hfAllTemplates" value="<?php echo clean(str_replace('"',"'", str_replace("'", "\'", json_encode($all_templates_array)))) ?>"/> <input type="hidden" id="hfTasks" value="<?php echo clean(str_replace('"',"'", str_replace("'", "\'", json_encode($tasks_array)))) ?>"/> <input type="hidden" id="hfIMilestones" value="<?php echo clean(str_replace('"',"'", str_replace("'", "\'", json_encode($internal_milestones_array)))) ?>"/> <input type="hidden" id="hfEMilestones" value="<?php echo clean(str_replace('"',"'", str_replace("'", "\'", json_encode($external_milestones_array)))) ?>"/> <input type="hidden" id="hfUsers" value="<?php echo clean(str_replace('"',"'", str_replace("'", "\'", json_encode($users_array)))) ?>"/> <input type="hidden" id="hfAllUsers" value="<?php echo clean(str_replace('"',"'", str_replace("'", "\'", json_encode($allUsers_array)))) ?>"/> <input type="hidden" id="hfCompanies" value="<?php echo clean(str_replace('"',"'", str_replace("'", "\'", json_encode($companies_array)))) ?>"/> <input type="hidden" id="hfUserPreferences" value="<?php echo clean(str_replace('"',"'", str_replace("'", "\'", json_encode($userPreferences)))) ?>"/> <input type="hidden" id="hfObjectSubtypes" value="<?php echo clean(str_replace('"',"'", str_replace("'", "\'", json_encode($object_subtypes_array)))) ?>"/> <input type="hidden" id="hfDependencyCount" value="<?php echo clean(str_replace('"',"'", str_replace("'", "\'", json_encode($dependency_count)))) ?>"/>
function index() { require_javascript("og/modules/plugins.js"); $this->scanPlugins(); // If there are plguins not scanned $plugins = Plugins::instance()->findAll(array("order" => "name ASC")); tpl_assign('plugins', $plugins); return $plugins; }
og.additional_on_dimension_object_click = []; og.dimension_object_types = []; <?php $dimension_object_types = ObjectTypes::findAll(array('conditions' => "`type` IN ('dimension_object', 'dimension_group')")); foreach ($dimension_object_types as $dot) { ?> og.dimension_object_types[<?php echo $dot->getId(); ?> ] = '<?php echo $dot->getName(); ?> '; <?php } foreach (Plugins::instance()->getActive() as $p) { $js_code = 'if (og.' . $p->getName() . ' && og.' . $p->getName() . '.init) og.' . $p->getName() . '.init();' . "\n"; echo $js_code; } ?> og.dimension_object_type_contents = []; <?php $dotcs = DimensionObjectTypeContents::findAll(); foreach ($dotcs as $dotc) { /* @var $dotc DimensionObjectTypeContent */ ?> var dim = <?php echo $dotc->getDimensionId(); ?> ;
function list_files() { ajx_current("empty"); // get query parameters $start = (int) array_var($_GET, 'start'); $limit = (int) array_var($_GET, 'limit'); if (!$start) { $start = 0; } if (!$limit) { $limit = config_option('files_per_page'); } $order = array_var($_GET, 'sort'); $order_dir = array_var($_GET, 'dir'); $page = (int) ($start / $limit) + 1; $hide_private = !logged_user()->isMemberOfOwnerCompany(); $type = array_var($_GET, 'type'); $user = array_var($_GET, 'user'); // if there's an action to execute, do so if (array_var($_GET, 'action') == 'delete') { $ids = explode(',', array_var($_GET, 'objects')); $succ = 0; $err = 0; foreach ($ids as $id) { $file = ProjectFiles::findById($id); if (isset($file) && $file->canDelete(logged_user())) { try { DB::beginWork(); $file->trash(); DB::commit(); ApplicationLogs::createLog($file, ApplicationLogs::ACTION_TRASH); $succ++; } catch (Exception $e) { DB::rollback(); $err++; } } else { if (!$file instanceof ProjectFile) { evt_add("popup", array('title' => lang('error'), 'message' => lang("file dnx"))); } else { if (!$file->canDelete(logged_user())) { evt_add("popup", array('title' => lang('error'), 'message' => lang("cannot delete file", $file->getObjectName()))); } } $err++; } } if ($succ > 0) { flash_success(lang("success delete files", $succ)); } else { flash_error(lang("error delete files", $err)); } } else { if (array_var($_GET, 'action') == 'markasread') { $ids = explode(',', array_var($_GET, 'objects')); $succ = 0; $err = 0; foreach ($ids as $id) { $file = ProjectFiles::findById($id); try { $file->setIsRead(logged_user()->getId(), true); $succ++; } catch (Exception $e) { $err++; } // try } //for if ($succ <= 0) { flash_error(lang("error markasread files", $err)); } } else { if (array_var($_GET, 'action') == 'markasunread') { $ids = explode(',', array_var($_GET, 'objects')); $succ = 0; $err = 0; foreach ($ids as $id) { $file = ProjectFiles::findById($id); try { $file->setIsRead(logged_user()->getId(), false); $succ++; } catch (Exception $e) { $err++; } // try } //for if ($succ <= 0) { flash_error(lang("error markasunread files", $err)); } } else { if (array_var($_GET, 'action') == 'zip_add') { $this->zip_add(); } else { if (array_var($_GET, 'action') == 'archive') { $ids = explode(',', array_var($_GET, 'ids')); $succ = 0; $err = 0; foreach ($ids as $id) { $file = ProjectFiles::findById($id); if (isset($file) && $file->canEdit(logged_user())) { try { DB::beginWork(); $file->archive(); DB::commit(); ApplicationLogs::createLog($file, ApplicationLogs::ACTION_ARCHIVE); $succ++; } catch (Exception $e) { DB::rollback(); $err++; } } else { $err++; } } if ($succ > 0) { flash_success(lang("success archive objects", $succ)); } else { flash_error(lang("error archive objects", $err)); } } } } } } Hook::fire('classify_action', null, $ret); $join_params = null; $select_columns = null; $extra_conditions = ""; if (strpos($order, 'p_') == 1) { $cpId = substr($order, 3); $order = 'customProp'; } if ($order == ProjectFiles::ORDER_BY_POSTTIME) { $order = '`created_on`'; } else { if ($order == ProjectFiles::ORDER_BY_MODIFYTIME) { $order = '`updated_on`'; } else { if ($order == ProjectFiles::ORDER_BY_SIZE) { $order = '`jt`.`filesize`'; $join_params = array('table' => ProjectFileRevisions::instance()->getTableName(), 'jt_field' => 'file_id', 'e_field' => 'object_id'); $extra_conditions .= " AND `jt`.`object_id` = (SELECT max(`x`.`object_id`) FROM " . TABLE_PREFIX . "project_file_revisions `x` WHERE `x`.`file_id` = `e`.`object_id`)"; } else { if ($order == 'customProp') { $order = 'IF(ISNULL(jt.value),1,0),jt.value'; $join_params['join_type'] = "LEFT "; $join_params['table'] = "" . TABLE_PREFIX . "custom_property_values"; $join_params['jt_field'] = "object_id"; $join_params['e_field'] = "object_id"; $join_params['on_extra'] = "AND custom_property_id = " . $cpId; $extra_conditions .= " AND ( custom_property_id = " . $cpId . " OR custom_property_id IS NULL)"; $select_columns = array("DISTINCT o.*", "e.*"); } else { $order = '`name`'; } } } } // if $extra_conditions .= $hide_private ? 'AND `is_visible` = 1' : ''; // filter attachments of other people if not filtering $tmp_mids = array(); foreach (active_context() as $selection) { if ($selection instanceof Member) { $d = $selection->getDimension(); if ($d instanceof Dimension && $d->getIsManageable()) { $tmp_mids[] = $selection->getId(); } } } if (count($tmp_mids) == 0) { if (Plugins::instance()->isActivePlugin('mail')) { $extra_conditions .= " AND IF(e.mail_id=0, true, EXISTS (SELECT mac.contact_id FROM " . TABLE_PREFIX . "mail_account_contacts mac \r\n\t\t\t\t\tWHERE mac.contact_id=o.created_by_id AND mac.account_id=(SELECT mc.account_id FROM " . TABLE_PREFIX . "mail_contents mc WHERE mc.object_id=e.mail_id)))"; } } Hook::fire("listing_extra_conditions", null, $extra_conditions); $only_count_result = array_var($_GET, 'only_result', false); $context = active_context(); $objects = ProjectFiles::instance()->listing(array("order" => $order, "order_dir" => $order_dir, "extra_conditions" => $extra_conditions, "show_only_member_objects" => user_config_option('show_only_member_files'), 'count_results' => false, 'only_count_results' => $only_count_result, "join_params" => $join_params, "start" => $start, "limit" => $limit, "select_columns" => $select_columns)); $custom_properties = CustomProperties::getAllCustomPropertiesByObjectType(ProjectFiles::instance()->getObjectTypeId()); // prepare response object $listing = array("totalCount" => $objects->total, "start" => $start, "objType" => ProjectFiles::instance()->getObjectTypeId(), "files" => array()); if (is_array($objects->objects)) { $index = 0; $ids = array(); foreach ($objects->objects as $o) { $coName = ""; $coId = $o->getCheckedOutById(); if ($coId != 0) { if ($coId == logged_user()->getId()) { $coName = "self"; } else { $coUser = Contacts::findById($coId); if ($coUser instanceof Contact) { $coName = $coUser->getObjectName(); } else { $coName = ""; } } } if ($o->isMP3()) { $songname = $o->getProperty("songname"); $artist = $o->getProperty("songartist"); $album = $o->getProperty("songalbum"); $track = $o->getProperty("songtrack"); $year = $o->getProperty("songyear"); $duration = $o->getProperty("songduration"); $songInfo = json_encode(array($songname, $artist, $album, $track, $year, $duration, $o->getDownloadUrl(), $o->getFilename(), $o->getId())); } else { $songInfo = array(); } $ids[] = $o->getId(); $values = array("id" => $o->getId(), "ix" => $index++, "object_id" => $o->getId(), "ot_id" => $o->getObjectTypeId(), "name" => $o->getObjectName(), "type" => $o->getTypeString(), "mimeType" => $o->getTypeString(), "createdBy" => clean($o->getCreatedByDisplayName()), "createdById" => $o->getCreatedById(), "dateCreated" => $o->getCreatedOn() instanceof DateTimeValue ? $o->getCreatedOn()->isToday() ? format_time($o->getCreatedOn()) : format_datetime($o->getCreatedOn()) : '', "dateCreated_today" => $o->getCreatedOn() instanceof DateTimeValue ? $o->getCreatedOn()->isToday() : 0, "updatedBy" => clean($o->getUpdatedByDisplayName()), "updatedById" => $o->getUpdatedById(), "dateUpdated" => $o->getUpdatedOn() instanceof DateTimeValue ? $o->getUpdatedOn()->isToday() ? format_time($o->getUpdatedOn()) : format_datetime($o->getUpdatedOn()) : '', "dateUpdated_today" => $o->getUpdatedOn() instanceof DateTimeValue ? $o->getUpdatedOn()->isToday() : 0, "icon" => $o->getTypeIconUrl(), "size" => format_filesize($o->getFileSize()), "url" => $o->getOpenUrl(), "manager" => get_class($o->manager()), "checkedOutByName" => $coName, "checkedOutById" => $coId, "isModifiable" => $o->isModifiable() && $o->canEdit(logged_user()), "modifyUrl" => $o->getModifyUrl(), "songInfo" => $songInfo, "ftype" => $o->getType(), "url" => $o->getUrl(), "memPath" => json_encode($o->getMembersIdsToDisplayPath()), "genid" => gen_id()); if ($o->isMP3()) { $values['isMP3'] = true; } Hook::fire('add_classification_value', $o, $values); foreach ($custom_properties as $cp) { $values['cp_' . $cp->getId()] = get_custom_property_value_for_listing($cp, $o); } $listing["files"][] = $values; } $read_objects = ReadObjects::getReadByObjectList($ids, logged_user()->getId()); foreach ($listing["files"] as &$data) { $data['isRead'] = isset($read_objects[$data['object_id']]); } ajx_extra_data($listing); tpl_assign("listing", $listing); } else { throw new Error("Not array", $code); } }
<?php if (false && count($selected_members) > 0) { ?> App.modules.addMemberForm.drawDimensionProperties('<?php echo $genid; ?> ', <?php echo $current_dimension->getId(); ?> ); <?php } ?> <?php if (!Plugins::instance()->isActivePlugin('member_custom_properties')) { ?> document.getElementById(genid + 'member_color_input').innerHTML = og.getColorInputHtml(genid, 'member', <?php echo "{$member_color}"; ?> , 'color', '<?php echo lang('color'); ?> '); <?php } ?> <?php if (isset($obj_type_sel) && $obj_type_sel) { ?>
foreach ($ctrl->index() as $plg) { /* @var $plg Plugin */ echo "---------------------------------------------\n"; echo "NAME: \t\t" . $plg->getSystemName() . "\n"; echo "VERSION: \t" . $plg->getVersion() . "\n"; echo "STATUS: \t" . ($plg->isInstalled() ? 'Installed ' : 'Uninstalled ') . ($plg->isActive() ? 'Activated ' : 'Inactive ') . "\n"; if ($plg->updateAvailable()) { echo "*** There is a new version of this plugin *** \n"; } } } else { if ($command == 'update_all') { $ctrl->updateAll(); } else { $arg1 or die("Plugin is required \n{$usage}"); $plg = Plugins::instance()->findOne(array("conditions" => " name = '{$arg1}'")); $plg or die("ERROR: plugin {$arg1} not found\n"); switch ($command) { case 'update': $ctrl->update($plg->getId()); break; case 'install': $ctrl->install($plg->getId()); break; case 'activate': $plg->activate(); break; case 'deactivate': $plg->deactivate(); break; case 'uninstall':
/** * @param array of string $pluginNames */ static function executeInstaller($name) { $table_prefix = TABLE_PREFIX; tpl_assign('table_prefix', $table_prefix); $default_charset = 'DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'; tpl_assign('default_charset', $default_charset); $default_collation = 'collate utf8_unicode_ci'; tpl_assign('default_collation', $default_collation); $engine = DB_ENGINE; tpl_assign('engine', $engine); try { $path = ROOT . "/plugins/{$name}/info.php"; if (file_exists($path)) { DB::beginWork(); $pluginInfo = (include_once $path); //0. Check if exists in plg table $sql = "SELECT id FROM " . TABLE_PREFIX . "plugins WHERE name = '{$name}' "; $plg_obj = DB::executeOne($sql); if (!$plg_obj) { //1. Insert into PLUGIN TABLE $cols = "name, is_installed, is_activated, version"; $values = "'{$name}', 1, 1 ,'" . array_var($pluginInfo, 'version') . "'"; if (is_numeric(array_var($pluginInfo, 'id'))) { $cols = "id, " . $cols; $values = array_var($pluginInfo, 'id') . ", " . $values; } $sql = "INSERT INTO " . TABLE_PREFIX . "plugins ({$cols}) VALUES ({$values}) ON DUPLICATE KEY UPDATE version='" . array_var($pluginInfo, 'version') . "'"; DB::executeOne($sql); $id = DB::lastInsertId(); $pluginInfo['id'] = $id; } else { $id = $plg_obj['id']; $pluginInfo['id'] = $id; } if (isset($pluginInfo['dependences']) && is_array($pluginInfo['dependences'])) { foreach ($pluginInfo['dependences'] as $dep_plugin_name) { if (!Plugins::instance()->isActivePlugin($dep_plugin_name)) { throw new Exception("To install this plugin you need to install '{$dep_plugin_name}' first."); } } } //2. IF Plugin defines types, INSERT INTO ITS TABLE if (count(array_var($pluginInfo, 'types'))) { foreach ($pluginInfo['types'] as $k => $type) { if (isset($type['name'])) { $sql = "\r\n\t\t\t\t\t\t\tINSERT INTO " . TABLE_PREFIX . "object_types (name, handler_class, table_name, type, icon, plugin_id)\r\n\t\t\t\t\t\t\t \tVALUES (\r\n\t\t\t\t\t\t\t \t'" . array_var($type, "name") . "', \r\n\t\t\t\t\t\t\t \t'" . array_var($type, "handler_class") . "', \r\n\t\t\t\t\t\t\t \t'" . array_var($type, "table_name") . "', \r\n\t\t\t\t\t\t\t \t'" . array_var($type, "type") . "', \r\n\t\t\t\t\t\t\t \t'" . array_var($type, "icon") . "', \r\n\t\t\t\t\t\t\t\t{$id}\r\n\t\t\t\t\t\t\t) ON DUPLICATE KEY UPDATE name=name"; DB::executeOne($sql); $last_id = DB::lastInsertId(); $pluginInfo['types'][$k]['id'] = $last_id; $type['id'] = $last_id; } } } //2. IF Plugin defines tabs, INSERT INTO ITS TABLE if (count(array_var($pluginInfo, 'tabs'))) { foreach ($pluginInfo['tabs'] as $k => $tab) { if (isset($tab['title'])) { $type_id = array_var($type, "id"); $sql = "\r\n\t\t\t\t\t\t\tINSERT INTO " . TABLE_PREFIX . "tab_panels (\r\n\t\t\t\t\t\t\t\tid,\r\n\t\t\t\t\t\t\t\ttitle, \r\n\t\t\t\t\t\t\t\ticon_cls, \r\n\t\t\t\t\t\t\t\trefresh_on_context_change, \r\n\t\t\t\t\t\t\t\tdefault_controller, \r\n\t\t\t\t\t\t\t\tdefault_action, \r\n\t\t\t\t\t\t\t\tinitial_controller, \r\n\t\t\t\t\t\t\t\tinitial_action, \r\n\t\t\t\t\t\t\t\tenabled, \r\n\t\t\t\t\t\t\t\ttype, \r\n\t\t\t\t\t\t\t\tplugin_id, \r\n\t\t\t\t\t\t\t\tobject_type_id )\r\n\t\t\t\t\t\t \tVALUES (\r\n\t\t\t\t\t\t \t\t'" . array_var($tab, 'id') . "', \r\n\t\t\t\t\t\t \t\t'" . array_var($tab, 'title') . "', \r\n\t\t\t\t\t\t \t\t'" . array_var($tab, 'icon_cls') . "',\r\n\t\t\t\t\t\t \t\t'" . array_var($tab, 'refresh_on_context_change') . "',\r\n\t\t\t\t\t\t \t\t'" . array_var($tab, 'default_controller') . "',\r\n\t\t\t\t\t\t \t\t'" . array_var($tab, 'default_action') . "',\r\n\t\t\t\t\t\t\t\t'" . array_var($tab, 'initial_controller') . "',\r\n\t\t\t\t\t\t\t\t'" . array_var($tab, 'initial_action') . "',\r\n\t\t\t\t\t\t\t\t'" . array_var($tab, 'enabled', 1) . "',\r\n\t\t\t\t\t\t\t\t'" . array_var($tab, 'type') . "',\r\n\t\t\t\t\t\t\t\t{$id},\r\n\t\t\t\t\t\t\t\t" . array_var($tab, 'object_type_id') . "\r\n\t\t\t\t\t\t\t) ON DUPLICATE KEY UPDATE \r\n\t\t\t\t\t\t\t\tid = VALUES(`id`), \r\n\t\t\t\t\t\t\t\ttitle = VALUES(`title`), \r\n\t\t\t\t\t\t\t\ticon_cls = VALUES(`icon_cls`), \r\n\t\t\t\t\t\t\t\trefresh_on_context_change = VALUES(`refresh_on_context_change`), \r\n\t\t\t\t\t\t\t\tdefault_controller = VALUES(`default_controller`), \r\n\t\t\t\t\t\t\t\tdefault_action = VALUES(`default_action`), \r\n\t\t\t\t\t\t\t\tinitial_controller = VALUES(`initial_controller`), \r\n\t\t\t\t\t\t\t\tinitial_action = VALUES(`initial_action`), \r\n\t\t\t\t\t\t\t\tenabled = VALUES(`enabled`), \r\n\t\t\t\t\t\t\t\ttype = VALUES(`type`), \r\n\t\t\t\t\t\t\t\tplugin_id = VALUES(`plugin_id`),\r\n\t\t\t\t\t\t\t\tobject_type_id = VALUES(`object_type_id`);\r\n\t\t\t\t\t\t\t"; DB::executeOne($sql); // INSERT INTO TAB PANEL PERMISSSION $sql = "\r\n\t\t\t\t\t\t\tINSERT INTO " . TABLE_PREFIX . "tab_panel_permissions (\r\n\t\t\t\t\t\t\t\tpermission_group_id,\r\n\t\t\t\t\t\t\t\ttab_panel_id \r\n\t\t\t\t\t\t\t)\r\n\t\t\t\t\t\t \tVALUES ( 1,'" . array_var($tab, 'id') . "' ), ( 2,'" . array_var($tab, 'id') . "' ) ON DUPLICATE KEY UPDATE permission_group_id = permission_group_id "; DB::executeOne($sql); } } } // Create schema sql query $schema_creation = ROOT . "/plugins/{$name}/install/sql/mysql_schema.php"; if (file_exists($schema_creation)) { $total_queries = 0; $executed_queries = 0; executeMultipleQueries(tpl_fetch($schema_creation), $total_queries, $executed_queries); Logger::log("Schema created for plugin {$name}"); } // Create schema sql query $schema_query = ROOT . "/plugins/{$name}/install/sql/mysql_initial_data.php"; if (file_exists($schema_query)) { $total_queries = 0; $executed_queries = 0; executeMultipleQueries(tpl_fetch($schema_query), $total_queries, $executed_queries); Logger::log("Initial data loaded for plugin '{$name}'." . mysql_error()); } $install_script = ROOT . "/plugins/{$name}/install/install.php"; if (file_exists($install_script)) { include_once $install_script; } DB::commit(); return true; } } catch (Exception $e) { //echo $e->getMessage(); DB::rollback(); throw $e; } return false; }
static function addObjToSharingTable($oid, $tid, $obj_mem_ids) { $gids = array(); $table_prefix = defined('FORCED_TABLE_PREFIX') && FORCED_TABLE_PREFIX ? FORCED_TABLE_PREFIX : TABLE_PREFIX; //1. clear sharing table for this object SharingTables::delete("object_id={$oid}"); //2. get dimensions of this object's members that defines permissions $res = DB::execute("SELECT d.id as did FROM " . $table_prefix . "dimensions d INNER JOIN " . $table_prefix . "members m on m.dimension_id=d.id\r\n\t\t\t\tWHERE m.id IN ( SELECT member_id FROM " . $table_prefix . "object_members WHERE object_id = {$oid} AND is_optimization = 0 ) AND d.defines_permissions = 1"); $dids_tmp = array(); while ($row = $res->fetchRow()) { $dids_tmp[$row['did']] = $row['did']; } $res->free(); $dids = array_values($dids_tmp); $dids_tmp = null; $sql_from = "" . $table_prefix . "contact_member_permissions cmp\r\n\t\tLEFT JOIN " . $table_prefix . "members m ON m.id = cmp.member_id\r\n\t\tLEFT JOIN " . $table_prefix . "dimensions d ON d.id = m.dimension_id"; $member_where_conditions = ""; $dim_where_conditions = ""; // if users can add objects without classifying then check for permissions with member_id=0 if (config_option('let_users_create_objects_in_root')) { $member_where_conditions = "member_id=0 OR "; $dim_where_conditions = " OR d.id IS NULL"; } $sql_where = "({$member_where_conditions} member_id IN ( SELECT member_id FROM " . $table_prefix . "object_members WHERE object_id = {$oid} AND is_optimization = 0)) AND cmp.object_type_id = {$tid}"; //3. If there are dimensions that defines permissions containing any of the object members if (count($dids)) { // 3.1 get permission groups with permissions over the object. $sql_fields = "permission_group_id AS group_id"; $sql = "\r\n\t\t\t\tSELECT\r\n\t\t\t\t{$sql_fields}\r\n\t\t\t\tFROM\r\n\t\t\t\t{$sql_from}\r\n\t\t\t\tWHERE\r\n\t\t\t\t{$sql_where} AND (d.id IN (" . implode(',', $dids) . ") {$dim_where_conditions})\r\n\t\t\t"; $res = DB::execute($sql); $gids_tmp = array(); while ($row = $res->fetchRow()) { $gids_tmp[$row['group_id']] = $row['group_id']; } $res->free(); // allow all permission groups $allow_all_rows = DB::executeAll("SELECT DISTINCT permission_group_id FROM " . $table_prefix . "contact_dimension_permissions cdp\r\n\t\t\t\t\tINNER JOIN " . $table_prefix . "members m on m.dimension_id=cdp.dimension_id\r\n\t\t\t\t\tWHERE cdp.permission_type='allow all' AND cdp.dimension_id IN (" . implode(',', $dids) . ");"); if (is_array($allow_all_rows)) { foreach ($allow_all_rows as $row) { $gids_tmp[$row['permission_group_id']] = $row['permission_group_id']; } } $gids = array_values($gids_tmp); $gids_tmp = null; // check for mandatory dimensions $enabled_dimensions_sql = ""; $enabled_dimensions_ids = implode(',', config_option('enabled_dimensions')); if ($enabled_dimensions_ids != "") { $enabled_dimensions_sql = "AND id IN ({$enabled_dimensions_ids})"; } $mandatory_dim_ids = Dimensions::findAll(array('id' => true, 'conditions' => "`defines_permissions`=1 {$enabled_dimensions_sql} AND `permission_query_method`='" . DIMENSION_PERMISSION_QUERY_METHOD_MANDATORY . "'")); if (count($gids) > 0 && count($mandatory_dim_ids) > 0) { $sql = "SELECT om.member_id, m.dimension_id FROM " . $table_prefix . "object_members om\r\n\t\t\t\t\tINNER JOIN " . $table_prefix . "members m ON m.id=om.member_id INNER JOIN " . $table_prefix . "dimensions d ON d.id=m.dimension_id\r\n\t\t\t\t\tWHERE om.object_id = {$oid} AND om.is_optimization = 0 AND d.id IN (" . implode(",", $mandatory_dim_ids) . ")"; // Object members in mandatory dimensions $object_member_ids_res = DB::executeAll($sql); $mandatory_dim_members = array(); if (!is_null($object_member_ids_res)) { foreach ($object_member_ids_res as $row) { if (!isset($mandatory_dim_members[$row['dimension_id']])) { $mandatory_dim_members[$row['dimension_id']] = array(); } $mandatory_dim_members[$row['dimension_id']][] = $row['member_id']; } $mandatory_dim_allowed_pgs = array(); // Check foreach group that it has permissions over at least one member of each mandatory dimension foreach ($mandatory_dim_members as $mdim_id => $mmember_ids) { $sql = "SELECT pg.id FROM " . $table_prefix . "permission_groups pg\r\n\t\t\t\t\t\t\tINNER JOIN " . $table_prefix . "contact_dimension_permissions cdp ON cdp.permission_group_id=pg.id\r\n\t\t\t\t\t\t\tINNER JOIN " . $table_prefix . "contact_member_permissions cmp ON cmp.permission_group_id=pg.id\r\n\t\t\t\t\t\t\tWHERE cdp.dimension_id = '{$mdim_id}' AND (\r\n\t\t\t\t\t\t\tcdp.permission_type='allow all' OR cdp.permission_type='check' AND cmp.permission_group_id IN (" . implode(',', $gids) . ")\r\n\t\t\t\t\t\t\tAND cmp.member_id IN (" . implode(',', $mmember_ids) . ")\r\n\t\t\t\t\t\t)"; $permission_groups_res = DB::executeAll($sql); $mandatory_dim_allowed_pgs[$mdim_id] = array(); if (!is_null($permission_groups_res)) { foreach ($permission_groups_res as $row) { if (!in_array($row['id'], $mandatory_dim_allowed_pgs[$mdim_id])) { $mandatory_dim_allowed_pgs[$mdim_id][] = $row['id']; } } } } if (isset($mandatory_dim_allowed_pgs) && count($mandatory_dim_allowed_pgs) > 0) { $original_mandatory_dim_allowed_pgs = $mandatory_dim_allowed_pgs; $allowed_gids = array_pop($mandatory_dim_allowed_pgs); foreach ($mandatory_dim_allowed_pgs as $pg_array) { $allowed_gids = array_intersect($allowed_gids, $pg_array); } // If an user has permissions in one dim using a group and in other dim using his personal permissions then add to sharing table its personal permission group $pg_ids = array_unique(array_flat($original_mandatory_dim_allowed_pgs)); if (count($pg_ids) == 0) { $pg_ids[0] = 0; } $contact_pgs = array(); $contact_pg_rows = DB::executeAll("SELECT * FROM " . TABLE_PREFIX . "contact_permission_groups WHERE permission_group_id IN (" . implode(',', $pg_ids) . ") ORDER BY permission_group_id"); if (is_array($contact_pg_rows)) { foreach ($contact_pg_rows as $cpgr) { if (!isset($contact_pgs[$cpgr['contact_id']])) { $contact_pgs[$cpgr['contact_id']] = array(); } $contact_pgs[$cpgr['contact_id']][] = $cpgr['permission_group_id']; } } // each user must have at least one pg for every dimension foreach ($contact_pgs as $contact_id => $permission_groups) { $has_one = array_flip(array_keys($original_mandatory_dim_allowed_pgs)); foreach ($has_one as $k => &$v) { $v = false; } foreach ($permission_groups as $pg_id) { foreach ($original_mandatory_dim_allowed_pgs as $dim_id => $allowedpgs) { if (in_array($pg_id, $allowedpgs)) { $has_one[$dim_id] = true; break; } } } // all dims must be true in this array to allow permissions $has_permission = !in_array(false, $has_one); if ($has_permission) { $contact_row = DB::executeOne("SELECT permission_group_id FROM " . TABLE_PREFIX . "contacts where object_id = {$contact_id}"); if (is_array($contact_row) && $contact_row['permission_group_id'] > 0) { $allowed_gids[] = $contact_row['permission_group_id']; } } } $gids = array_unique($allowed_gids, SORT_NUMERIC); } else { $gids = array(); } } } } else { if ($obj_mem_ids) { // 3.2 No memeber dimensions defines permissions. // No esta en ninguna dimension que defina permisos, El objecto esta en algun lado // => En todas las dimensiones en la que está no definen permisos => Busco todos los grupos $gids = PermissionGroups::instance()->findAll(array('id' => true, 'conditions' => "type != 'roles'")); } else { // if this object is an email and it is unclassified => add to sharing table the permission groups of the users that have permissions in the email's account if (Plugins::instance()->isActivePlugin('mail')) { $mail_ot = ObjectTypes::instance()->findByName('mail'); if ($mail_ot instanceof ObjectType && $tid == $mail_ot->getId()) { $gids = array_flat(DB::executeAll("\r\n\t\t\t\t\t\t\tSELECT cpg.permission_group_id\r\n\t\t\t\t\t\t\tFROM " . TABLE_PREFIX . "contact_permission_groups cpg\r\n\t\t\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "contacts c ON c.permission_group_id=cpg.permission_group_id\r\n\t\t\t\t\t\t\tWHERE cpg.contact_id IN (\r\n\t\t\t\t\t\t\t SELECT mac.contact_id FROM " . TABLE_PREFIX . "mail_account_contacts mac WHERE mac.account_id = (SELECT mc.account_id FROM " . TABLE_PREFIX . "mail_contents mc WHERE mc.object_id={$oid})\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t")); } } } } if (count($gids)) { $stManager = SharingTables::instance(); $stManager->populateGroups($gids, $oid); $gids = null; } }
/** * Edit task * * @access public * @param void * @return null */ function edit_task() { $isTemplateTask = false; if (array_var($_REQUEST, 'template_task') == true) { $isTemplateTask = true; } if (logged_user()->isGuest()) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $this->setTemplate('add_task'); if (array_var($_REQUEST, "template_task")) { $task = TemplateTasks::findById(array_var($_REQUEST, "template_task_id", get_id())); $this->setTemplate(get_template_path('add_template_task', 'template_task')); if (array_var($_REQUEST, 'template_id')) { $template_id = array_var($_REQUEST, 'template_id'); } else { $template_id = $task->getTemplateId(); } tpl_assign('additional_tt_params', array_var($_REQUEST, 'additional_tt_params')); tpl_assign('template_id', $template_id); if (!$task instanceof TemplateTask) { flash_error(lang('task list dnx')); ajx_current("empty"); return; } // if } else { $task = ProjectTasks::findById(get_id()); if (!$task instanceof ProjectTask) { flash_error(lang('task list dnx')); ajx_current("empty"); return; } // if if (!$task->canEdit(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if } if (array_var($_GET, 'replace')) { ajx_replace(true); } $task_data = array_var($_POST, 'task'); $time_estimate = array_var($_POST, 'hours', 0) * 60 + array_var($_POST, 'minutes', 0); if ($time_estimate > 0) { $estimatedTime = $time_estimate; } else { $estimatedTime = $task->getTimeEstimate(); } if (!is_array($task_data)) { // set layout for modal form if (array_var($_REQUEST, 'modal')) { $this->setLayout("json"); tpl_assign('modal', true); } $this->getRepeatOptions($task, $occ, $rsel1, $rsel2, $rsel3, $rnum, $rend, $rjump); $dd = $task->getDueDate() instanceof DateTimeValue ? $task->getDueDate() : null; if ($dd instanceof DateTimeValue && $task->getUseDueTime()) { $dd->advance(logged_user()->getTimezone() * 3600); } $sd = $task->getStartDate() instanceof DateTimeValue ? $task->getStartDate() : null; if ($sd instanceof DateTimeValue && $task->getUseStartTime()) { $sd->advance(logged_user()->getTimezone() * 3600); } $post_dd = null; if (array_var($_POST, 'task_due_date')) { $post_dd = getDateValue(array_var($_POST, 'task_due_date')); if ($post_dd instanceof DateTimeValue) { $duetime = getTimeValue(array_var($_POST, 'task_due_time')); if (is_array($duetime)) { $post_dd->setHour(array_var($duetime, 'hours')); $post_dd->setMinute(array_var($duetime, 'mins')); $post_dd->advance(logged_user()->getTimezone() * 3600); } } } $post_st = null; if (array_var($_POST, 'task_start_date')) { $post_st = getDateValue(array_var($_POST, 'task_start_date')); if ($post_st instanceof DateTimeValue) { $starttime = getTimeValue(array_var($_POST, 'task_start_time')); if (is_array($starttime)) { $post_st->setHour(array_var($starttime, 'hours')); $post_st->setMinute(array_var($starttime, 'mins')); $post_st->advance(logged_user()->getTimezone() * 3600); } } } if (config_option("wysiwyg_tasks")) { $text_post = preg_replace("/[\n|\r|\n\r]/", '', array_var($_POST, 'text', $task->getText())); } else { $text_post = array_var($_POST, 'text', $task->getText()); } $task_data = array('name' => array_var($_POST, 'name', $task->getObjectName()), 'text' => $text_post, 'milestone_id' => array_var($_POST, 'milestone_id', $task->getMilestoneId()), 'due_date' => getDateValue($post_dd, $dd), 'start_date' => getDateValue($post_st, $sd), 'parent_id' => $task->getParentId(), 'assigned_to_contact_id' => array_var($_POST, 'assigned_to_contact_id', $task->getAssignedToContactId()), 'selected_members_ids' => json_decode(array_var($_POST, 'members', null)), 'priority' => array_var($_POST, 'priority', $task->getPriority()), 'time_estimate' => $estimatedTime, 'percent_completed' => $task->getPercentCompleted(), 'forever' => $task->getRepeatForever(), 'rend' => $rend, 'rnum' => $rnum, 'rjump' => $rjump, 'rsel1' => $rsel1, 'rsel2' => $rsel2, 'rsel3' => $rsel3, 'occ' => $occ, 'repeat_by' => $task->getRepeatBy(), 'object_subtype' => array_var($_POST, "object_subtype", $task->getObjectSubtype() != 0 ? $task->getObjectSubtype() : config_option('default task co type')), 'type_content' => $task->getTypeContent(), 'multi_assignment' => $task->getColumnValue('multi_assignment', 0), 'send_notification_subscribers' => user_config_option("can notify subscribers")); // array //control dates of parent and subtasks $task_data['type_control'] = ""; $parent_data = $task->getParent(); if ($parent_data) { $task_data['type_control'] = "child"; $task_data['control_title'] = $parent_data->getObjectName(); $task_data['control_due_date'] = $parent_data->getDueDate() instanceof DateTimeValue ? $parent_data->getDueDate()->getTimestamp() + logged_user()->getTimezone() * 3600 : null; $task_data['control_start_date'] = $parent_data->getStartDate() instanceof DateTimeValue ? $parent_data->getStartDate()->getTimestamp() + logged_user()->getTimezone() * 3600 : null; } $subtask_data = $task->getAllSubTasks(); if ($subtask_data) { $task_data['type_control'] = "father"; $task_data['control_title'] = $task->getObjectName(); $task_data['control_due_date'] = getDateValue($post_dd, $dd) instanceof DateTimeValue ? getDateValue($post_dd, $dd)->getTimestamp() : null; $task_data['control_start_date'] = getDateValue($post_st, $sd) instanceof DateTimeValue ? getDateValue($post_st, $sd)->getTimestamp() : null; } } // if //I find all those related to the task to find out if the original $task_related = ProjectTasks::findByRelated($task->getObjectId()); if (!$task_related) { //is not the original as the original look plus other related if ($task->getOriginalTaskId() != "0") { $task_related = ProjectTasks::findByTaskAndRelated($task->getObjectId(), $task->getOriginalTaskId()); } } if ($task_related) { $pending_id = 0; foreach ($task_related as $t_rel) { if ($task->getStartDate() <= $t_rel->getStartDate() && $task->getDueDate() <= $t_rel->getDueDate() && !$t_rel->isCompleted()) { $pending_id = $t_rel->getId(); break; } } tpl_assign('pending_task_id', $pending_id); tpl_assign('task_related', true); } else { tpl_assign('pending_task_id', 0); tpl_assign('task_related', false); } tpl_assign('task', $task); tpl_assign('task_data', $task_data); if (is_array(array_var($_POST, 'task'))) { foreach ($task_data as $k => &$v) { $v = remove_scripts($v); } $send_edit = false; if ($task->getAssignedToContactId() == array_var($task_data, 'assigned_to_contact_id')) { $send_edit = true; } $old_owner = $task->getAssignedTo(); if (array_var($task_data, 'parent_id') == $task->getId()) { flash_error(lang("task own parent error")); ajx_current("empty"); return; } try { try { $task_data['due_date'] = getDateValue(array_var($_POST, 'task_due_date')); $task_data['start_date'] = getDateValue(array_var($_POST, 'task_start_date')); } catch (Exception $e) { throw new Exception(lang('date format error', date_format_tip(user_config_option('date_format')))); } if ($task_data['due_date'] instanceof DateTimeValue) { $duetime = getTimeValue(array_var($_POST, 'task_due_time')); if (is_array($duetime)) { $task_data['due_date']->setHour(array_var($duetime, 'hours')); $task_data['due_date']->setMinute(array_var($duetime, 'mins')); $task_data['due_date']->advance(logged_user()->getTimezone() * -3600); } $task_data['use_due_time'] = is_array($duetime); } if ($task_data['start_date'] instanceof DateTimeValue) { $starttime = getTimeValue(array_var($_POST, 'task_start_time')); if (is_array($starttime)) { $task_data['start_date']->setHour(array_var($starttime, 'hours')); $task_data['start_date']->setMinute(array_var($starttime, 'mins')); $task_data['start_date']->advance(logged_user()->getTimezone() * -3600); } $task_data['use_start_time'] = is_array($starttime); } //control date subtask whit parent if (array_var($_POST, 'control_dates') == "child") { $parent = $task->getParent(); if ($parent->getStartDate() instanceof DateTimeValue && $task_data['start_date'] instanceof DateTimeValue) { if ($task_data['start_date']->getTimestamp() < $parent->getStartDate()->getTimestamp()) { $parent->setStartDate($task_data['start_date']); $parent->setUseStartTime($task_data['use_start_time']); } } else { $parent->setStartDate($task_data['start_date']); $parent->setUseStartTime(array_var($task_data, 'use_start_time', 0)); } if ($parent->getDueDate() instanceof DateTimeValue && $task_data['due_date'] instanceof DateTimeValue) { if ($task_data['due_date']->getTimestamp() > $parent->getDueDate()->getTimestamp()) { $parent->setDueDate($task_data['due_date']); $parent->setUseDueTime($task_data['use_due_time']); } } else { $parent->setDueDate($task_data['due_date']); $parent->setUseDueTime(array_var($task_data, 'use_due_time', 0)); } // calculate and set estimated time $totalMinutes = array_var($task_data, 'time_estimate_hours') * 60 + array_var($task_data, 'time_estimate_minutes'); $parent->setTimeEstimate($totalMinutes); $parent->save(); } $err_msg = $this->setRepeatOptions($task_data); if ($err_msg) { throw new Exception($err_msg); } if (!isset($task_data['parent_id'])) { $task_data['parent_id'] = 0; } $member_ids = json_decode(array_var($_POST, 'members')); // keep old dates to check for subtasks $old_start_date = $task->getStartDate(); $old_due_date = $task->getDueDate(); if (config_option("wysiwyg_tasks")) { $task_data['type_content'] = "html"; $task_data['text'] = str_replace(array("\r", "\n", "\r\n"), array('', '', ''), array_var($task_data, 'text')); } else { $task_data['type_content'] = "text"; } $task->setFromAttributes($task_data); $totalMinutes = array_var($task_data, 'time_estimate_hours') * 60 + array_var($task_data, 'time_estimate_minutes'); $task->setTimeEstimate($totalMinutes); if ($task->getParentId() > 0 && $task->hasChild($task->getParentId())) { flash_error(lang('task child of child error')); ajx_current("empty"); return; } if (isset($task_data['percent_completed']) && $task_data['percent_completed'] >= 0 && $task_data['percent_completed'] <= 100) { $task->setPercentCompleted($task_data['percent_completed']); } DB::beginWork(); $task->save(); if (!isset($task_data['percent_completed'])) { $task->calculatePercentComplete(); } // dependencies if (config_option('use tasks dependencies')) { $previous_tasks = array_var($task_data, 'previous'); if (is_array($previous_tasks)) { foreach ($previous_tasks as $ptask) { if ($ptask == $task->getId()) { continue; } $dep = ProjectTaskDependencies::findById(array('previous_task_id' => $ptask, 'task_id' => $task->getId())); if (!$dep instanceof ProjectTaskDependency) { $dep = new ProjectTaskDependency(); $dep->setPreviousTaskId($ptask); $dep->setTaskId($task->getId()); $dep->save(); } } $saved_ptasks = ProjectTaskDependencies::findAll(array('conditions' => 'task_id = ' . $task->getId())); foreach ($saved_ptasks as $pdep) { if (!in_array($pdep->getPreviousTaskId(), $previous_tasks)) { $pdep->delete(); } } } else { ProjectTaskDependencies::delete('task_id = ' . $task->getId()); } } // Add assigned user to the subscibers list if ($task->getAssignedToContactId() > 0 && Contacts::instance()->findById($task->getAssignedToContactId())) { if (!isset($_POST['subscribers'])) { $_POST['subscribers'] = array(); } $_POST['subscribers']['user_' . $task->getAssignedToContactId()] = '1'; } $object_controller = new ObjectController(); if ($isTemplateTask) { $object_controller->add_to_members($task, $member_ids, null, false); } else { $object_controller->add_to_members($task, $member_ids); } $is_template = $task instanceof TemplateTask; $object_controller->add_subscribers($task, null, !$is_template); $object_controller->link_to_new_object($task); $object_controller->add_custom_properties($task); if (!$task->isCompleted()) { //to make sure the task it is not completed yet, and that it has subscribed people $old_reminders = ObjectReminders::getByObject($task); $object_controller->add_reminders($task); //adding the new reminders, if any $object_controller->update_reminders($task, $old_reminders); //updating the old ones if (logged_user() instanceof Contact && (!is_array($old_reminders) || count($old_reminders) == 0) && (user_config_option("add_task_autoreminder") && logged_user()->getId() != $task->getAssignedToContactId() || user_config_option("add_self_task_autoreminder") && logged_user()->getId() == $task->getAssignedToContactId())) { //if there is no asignee, but it still has subscribers $reminder = new ObjectReminder(); $def = explode(",", user_config_option("reminders_tasks")); $minutes = $def[2] * $def[1]; $reminder->setMinutesBefore($minutes); $reminder->setType($def[0]); $reminder->setContext("due_date"); $reminder->setObject($task); $reminder->setUserId(0); $date = $task->getDueDate(); if ($date instanceof DateTimeValue) { $rdate = new DateTimeValue($date->getTimestamp() - $minutes * 60); $reminder->setDate($rdate); } $reminder->save(); } } if (!is_array($member_ids) || count($member_ids) == 0) { $member_ids = array(0); } $members = Members::findAll(array('conditions' => "id IN (" . implode(',', $member_ids) . ")")); $task->apply_members_to_subtasks($members, true); // apply values to subtasks $assigned_to = $task->getAssignedToContactId(); $subtasks = $task->getAllSubTasks(); $milestone_id = $task->getMilestoneId(); $apply_ms = array_var($task_data, 'apply_milestone_subtasks'); $apply_at = array_var($task_data, 'apply_assignee_subtasks', ''); foreach ($subtasks as $sub) { $modified = false; //if ($apply_at || !($sub->getAssignedToContactId() > 0)) { if ($apply_at) { $sub->setAssignedToContactId($assigned_to); $modified = true; } if ($apply_ms) { $sub->setMilestoneId($milestone_id); $modified = true; } if ($modified) { $sub->save(); } //control date parent whit subtask if ($_POST['control_dates'] == "father") { if ($sub->getStartDate() instanceof DateTimeValue) { if ($task->getStartDate() instanceof DateTimeValue) { if ($task->getStartDate()->getTimestamp() > $sub->getStartDate()->getTimestamp()) { $sub->setStartDate($task->getStartDate()); } } } else { if ($task->getStartDate() instanceof DateTimeValue) { $sub->setStartDate($task->getStartDate()); } } $sub->setUseStartTime($task->getUseStartTime()); if ($sub->getDueDate() instanceof DateTimeValue) { if ($task->getDueDate() instanceof DateTimeValue) { if ($task->getDueDate()->getTimestamp() < $sub->getDueDate()->getTimestamp()) { $sub->setDueDate($task->getDueDate()); } } } else { if ($task->getDueDate() instanceof DateTimeValue) { $sub->setDueDate($task->getDueDate()); } } $sub->setUseDueTime($task->getUseDueTime()); $sub->save(); } } $task->resetIsRead(); $log_info = ''; if ($send_edit == true) { $log_info = $task->getAssignedToContactId(); } else { if ($send_edit == false) { $task->setAssignedBy(logged_user()); $task->save(); } } if (config_option('repeating_task') == 1) { $opt_rep_day['saturday'] = false; $opt_rep_day['sunday'] = false; if (array_var($task_data, 'repeat_saturdays', false)) { $opt_rep_day['saturday'] = true; } if (array_var($task_data, 'repeat_sundays', false)) { $opt_rep_day['sunday'] = true; } $this->repetitive_task($task, $opt_rep_day); } if (isset($_POST['type_related'])) { if ($_POST['type_related'] == "all" || $_POST['type_related'] == "news") { $task_data['members'] = json_decode(array_var($_POST, 'members')); unset($task_data['due_date']); unset($task_data['use_due_time']); unset($task_data['start_date']); unset($task_data['use_start_time']); $this->repetitive_tasks_related($task, "edit", $_POST['type_related'], $task_data); } } if (config_option('multi_assignment') && Plugins::instance()->isActivePlugin('crpm')) { if (array_var($task_data, 'multi_assignment_aplly_change') == 'subtask') { $null = null; Hook::fire('edit_subtasks', $task, $null); } } //for calculate member status we save de task again after the object have the members $task->save(); // save subtasks added in 'subtasks' tab $sub_tasks_to_log = $this->saveSubtasks($task, array_var($task_data, 'subtasks'), $member_ids); DB::commit(); foreach ($sub_tasks_to_log['add'] as $st_to_log) { ApplicationLogs::createLog($st_to_log, ApplicationLogs::ACTION_ADD); } foreach ($sub_tasks_to_log['edit'] as $st_to_log) { ApplicationLogs::createLog($st_to_log, ApplicationLogs::ACTION_EDIT); } foreach ($sub_tasks_to_log['trash'] as $st_to_log) { ApplicationLogs::createLog($st_to_log, ApplicationLogs::ACTION_TRASH); } //Send Template task to view if ($task instanceof TemplateTask) { $objectId = $task->getObjectId(); $id = $task->getId(); $objectTypeName = $task->getObjectTypeName(); $objectName = $task->getObjectName(); $manager = get_class($task->manager()); $milestoneId = $task instanceof TemplateTask ? $task->getMilestoneId() : '0'; $subTasks = $task->getSubTasks(); $parentId = $task->getParentId(); $ico = "ico-task"; $action = "edit"; $object = TemplateController::prepareObject($objectId, $id, $objectName, $objectTypeName, $manager, $action, $milestoneId, $subTasks, $parentId, $ico); $template_task_data = array('object' => $object); if (array_var($_REQUEST, 'additional_tt_params')) { $additional_tt_params = json_decode(str_replace("'", '"', array_var($_REQUEST, 'additional_tt_params')), true); foreach ($additional_tt_params as $k => $v) { $template_task_data[$k] = $v; } } if (!array_var($_REQUEST, 'modal')) { evt_add("template object added", $template_task_data); } } try { // notify asignee if (array_var($task_data, 'send_notification') && $task->getAssignedToContactId() != $task->getAssignedById()) { $new_owner = $task->getAssignedTo(); if ($new_owner instanceof Contact) { Notifier::taskAssigned($task); } // if } // if if (array_var($task_data, 'send_notification')) { foreach ($sub_tasks_to_log['assigned'] as $st_to_log) { Notifier::taskAssigned($st_to_log); } } } catch (Exception $e) { } // try //notify subscribers $isSilent = true; if (array_var($task_data, 'send_notification_subscribers')) { $isSilent = false; } ApplicationLogs::createLog($task, ApplicationLogs::ACTION_EDIT, false, false, true, $log_info); //flash_success(lang('success edit task list', $task->getObjectName())); if (array_var($_REQUEST, 'modal')) { if (array_var($_REQUEST, 'reload')) { evt_add("reload current panel"); } else { ajx_current("empty"); $this->setLayout("json"); $this->setTemplate(get_template_path("empty")); // reload task info because plugins may have updated some task info (for example: name prefix) if ($is_template) { $task = TemplateTasks::findById($task->getId()); } else { $task = ProjectTasks::findById($task->getId()); } $params = array('msg' => lang('success edit task list', $task->getObjectName()), 'task' => $task->getArrayInfo(), 'reload' => array_var($_REQUEST, 'reload')); if ($task instanceof TemplateTask) { //$params['msg'] = lang('success edit template', $task->getObjectName()); $params['object'] = $template_task_data['object']; } //print_modal_json_response($params, true, array_var($_REQUEST, 'use_ajx')); ajx_extra_data($params); } } else { ajx_current("back"); } // if has subtasks and dates were changed, ask the user if the subtasks dates should also be changed if ($task instanceof ProjectTask && $task->countOpenSubTasks() > 0) { // check if there was any due date changes $dd_advance_info = null; if ($task->getDueDate() instanceof DateTimeValue && $old_due_date instanceof DateTimeValue && $old_due_date->getTimestamp() != $task->getDueDate()->getTimestamp()) { $dd_to_advance_ts = $task->getDueDate()->getTimestamp() - $old_due_date->getTimestamp(); if ($dd_to_advance_ts != 0) { $dd_advance_info = get_time_info($dd_to_advance_ts); } } // check if there was any start date changes $sd_advance_info = null; if ($task->getStartDate() instanceof DateTimeValue && $old_start_date instanceof DateTimeValue && $old_start_date->getTimestamp() != $task->getStartDate()->getTimestamp()) { $sd_to_advance_ts = $task->getStartDate()->getTimestamp() - $old_start_date->getTimestamp(); if ($sd_to_advance_ts != 0) { $sd_advance_info = get_time_info($sd_to_advance_ts); } } if ($dd_advance_info != null || $sd_advance_info != null) { evt_add('ask to change subtasks dates', array('dd_diff' => $dd_advance_info, 'sd_diff' => $sd_advance_info, 'task_id' => $task->getId())); } } } catch (Exception $e) { DB::rollback(); if (array_var($_REQUEST, 'modal')) { $this->setLayout("json"); $this->setTemplate(get_template_path("empty")); print_modal_json_response(array('errorCode' => 1, 'errorMessage' => $e->getMessage(), 'showMessage' => 1), true, array_var($_REQUEST, 'use_ajx')); } else { flash_error($e->getMessage()); } ajx_current("empty"); } // try } // if }
/** * Initialize Morfy Plugins * * <code> * Plugins::init(); * </code> * * @access public */ public static function init() { if (!isset(self::$instance)) { self::$instance = new Plugins(); } return self::$instance; }
function get_javascript_translation_default() { $defaultLang = "en_us"; $content = "/* start */\n"; $fileDir = ROOT . "/language/" . $defaultLang; //Get Feng Office translation files $filenames = get_files($fileDir, "js"); sort($filenames); foreach ($filenames as $f) { $content .= "\n/* {$f} */\n"; $content .= "try {"; $content .= file_get_contents($f); $content .= "} catch (e) {}"; } // include all installed plugins, no matter if they they have not been activated $plugins = Plugins::instance()->getAll(); foreach ($plugins as $plugin) { $plg_dir = $plugin->getLanguagePath() . "/" . $defaultLang; if (is_dir($plg_dir)) { $files = get_files($plg_dir, 'js'); if (is_array($files)) { sort($files); foreach ($files as $file) { $content .= "\n/* {$file} */\n"; $content .= "try {"; /** * The js file can contain PHP code so use include instead of file_get_contents. * To avoid sending headers, use output buffer. * This change help to avoid the need of multiple lang files.. javascripts and phps. * You can create only one php file containing all traslations, * and this will populate client and server side langs datasorces */ ob_start(); include $file; $content .= ob_get_contents(); ob_end_clean(); //!important: Clean output buffer to save memory $content .= "} catch (e) {}"; } } } } $content .= "\n/* end */\n"; $content = str_replace("addLangs", "addLangsDefault", $content); $this->setLayout("json"); $this->renderText($content, true); }
/** * This function will return paginated result. Result is an array where first element is * array of returned object and second populated pagination object that can be used for * obtaining and rendering pagination data using various helpers. * * Items and pagination array vars are indexed with 0 for items and 1 for pagination * because you can't use associative indexing with list() construct * * @access public * @param array $arguments Query argumens (@see find()) Limit and offset are ignored! * @param integer $items_per_page Number of items per page * @param integer $current_page Current page number * @return array */ function paginate($arguments = null, $items_per_page = 10, $current_page = 1) { if (isset($this) && instance_of($this, 'Plugins')) { return parent::paginate($arguments, $items_per_page, $current_page); } else { return Plugins::instance()->paginate($arguments, $items_per_page, $current_page); //$instance =& Plugins::instance(); //return $instance->paginate($arguments, $items_per_page, $current_page); } // if }
function hasEmailAccounts() { $mail_plugin_enabled = Plugins::instance()->isActivePlugin('mail'); if ($mail_plugin_enabled) { $accounts = MailAccountContacts::find(array('conditions' => '`contact_id` = ' . $this->getId())); return is_array($accounts) && count($accounts) > 0; } }
} ?> <!--[if IE 7]> <?php echo stylesheet_tag("og/ie7.css"); ?> <![endif]--> <!--[if IE 8]> <?php echo stylesheet_tag("og/ie8.css"); ?> <![endif]--> <div class="header-container"> <div class="header"> <?php if (Plugins::instance()->isActivePlugin('custom_login')) { echo_custom_logo_url(); } else { ?> <a class="logo" href="http://www.fengoffice.com"></a> <?php } ?> </div> </div> <div class="login-body"> <form class="internalForm" action="<?php echo get_url('access', 'forgot_password'); ?> " method="post">
function do_mark_as_read_unread_objects($ids, $read, $mark_conversation = false) { $err = 0; // count errors $succ = 0; // count updated objects foreach ($ids as $id) { try { $obj = Objects::findObject($id); if ($obj instanceof ContentDataObject && logged_user() instanceof Contact) { $obj->setIsRead(logged_user()->getId(), $read); if (Plugins::instance()->isActivePlugin('mail')) { if ($obj instanceof MailContent && $mark_conversation) { $emails_in_conversation = MailContents::getMailsFromConversation($obj); foreach ($emails_in_conversation as $email) { $email->setIsRead(logged_user()->getId(), $read); } } } } $succ++; } catch (Exception $e) { $err++; } // try } return array($succ, $err); }