/** * Execute search * * @param void * @return null */ function search() { if (active_project() && !logged_user()->isProjectUser(active_project())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if $pageType = array_var($_GET, 'page_type'); $search_for = array_var($_GET, 'search_for'); $objectManagers = array("ProjectWebpages", "ProjectMessages", "MailContents", "ProjectFiles", "ProjectMilestones", "ProjectTasks", "ProjectEvents"); $objectTypes = array(lang('webpages'), lang('messages'), lang('emails'), lang('files'), lang('milestones'), lang('tasks'), lang('events')); $iconTypes = array('webpage', 'message', 'email', 'file', 'milestone', 'task', 'event'); if (user_config_option('show_file_revisions_search')) { array_splice($objectManagers, 4, 0, 'ProjectFileRevisions'); array_splice($objectTypes, 4, 0, lang('file contents')); array_splice($iconTypes, 4, 0, 'file'); } $search_results = array(); $timeBegin = microtime(true); if (trim($search_for) == '') { $search_results = null; $pagination = null; } else { $search_results = $this->searchWorkspaces($search_for, $search_results, 5); $search_results = $this->searchUsers($search_for, $search_results, 5); $search_results = $this->searchContacts($search_for, $search_results, 5); if (array_var($_GET, 'search_all_projects') != "true" && active_project() instanceof Project) { $projects = active_project()->getAllSubWorkspacesCSV(true); } else { $projects = null; } $c = 0; foreach ($objectManagers as $om) { $user_id = $om == "MailContents" ? logged_user()->getId() : 0; $results = SearchableObjects::searchByType($search_for, $projects, $om, true, 5, 1, null, $user_id); if (count($results[0]) > 0) { $sr = array(); $sr['result'] = $results[0]; $sr['pagination'] = $results[1]; $sr['type'] = $objectTypes[$c]; $sr['icontype'] = $iconTypes[$c]; $sr['manager'] = $om; $search_results[] = $sr; } $c++; } } // if $timeEnd = microtime(true); if (str_starts_with($search_for, '"') && str_ends_with($search_for, '"')) { $search_for = str_replace('"', '', $search_for); } tpl_assign('search_string', $search_for); tpl_assign('search_results', $search_results); tpl_assign('time', $timeEnd - $timeBegin); ajx_set_no_toolbar(true); ajx_replace(true); }
/** * Show account index page * * @access public * @param void * @return null */ function index() { $this->setHelp("account"); $this->setTemplate("card"); $this->setControllerName("user"); tpl_assign('user', logged_user()); ajx_set_no_toolbar(true); tpl_assign('logs', $logs); }
/** * Show account index page * * @access public * @param void * @return null */ function index() { $this->setHelp("account"); $this->setTemplate("card"); $this->setControllerName("user"); tpl_assign('user', logged_user()); ajx_set_no_toolbar(true); $pids = null; if (active_project() instanceof Project) { $pids = active_project()->getAllSubWorkspacesQuery(); } $logs = ApplicationLogs::getOverallLogs(false, false, $pids, 15, 0, get_id()); tpl_assign('logs', $logs); }
/** * Show view milestone page * * @access public * @param void * @return null */ function view() { $this->addHelper('textile'); $milestone = ProjectMilestones::findById(get_id()); if (!$milestone instanceof ProjectMilestone) { flash_error(lang('milestone dnx')); ajx_current("empty"); return; } // if if (!$milestone->canView(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if ajx_extra_data(array("title" => $milestone->getObjectName(), "urgent" => $milestone->getIsUrgent(), 'icon' => 'ico-milestone')); ajx_set_no_toolbar(true); tpl_assign('milestone', $milestone); ApplicationReadLogs::createLog($milestone, ApplicationReadLogs::ACTION_READ); }
/** * Show company card page * * @param void * @return null */ function card() { $this->setTemplate("view_company"); $company = Companies::findById(get_id()); if (!$company instanceof Company) { flash_error(lang('company dnx')); ajx_current("empty"); return; } // if if (!logged_user()->canSeeCompany($company)) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if ajx_set_no_toolbar(true); ajx_extra_data(array("title" => $company->getName(), 'icon' => 'ico-company')); tpl_assign('company', $company); ApplicationReadLogs::createLog($company, $company->getWorkspaces(), ApplicationReadLogs::ACTION_READ); }
/** * Show dashboard index page * * @param void * @return null */ function index() { $this->setHelp('dashboard'); $tag = array_var($_GET, 'active_tag'); $logged_user = logged_user(); if (active_project() instanceof Project) { $wscsv = active_project()->getAllSubWorkspacesQuery(true); } else { $wscsv = null; } $activity_log = null; $include_private = $logged_user->isMemberOfOwnerCompany(); $include_silent = $logged_user->isAdministrator(); $activity_log = ApplicationLogs::getOverallLogs($include_private, $include_silent, $wscsv, config_option('dashboard_logs_count', 15)); if (user_config_option('show charts widget') && module_enabled('reporting')) { $charts = ProjectCharts::getChartsAtProject(active_project(), active_tag()); tpl_assign('charts', $charts); if (BillingCategories::count() > 0 && active_project() instanceof Project) { tpl_assign('billing_chart_data', active_project()->getBillingTotalByUsers(logged_user())); } } if (user_config_option('show messages widget') && module_enabled('notes')) { list($messages, $pagination) = ProjectMessages::getMessages(active_tag(), active_project(), 0, 10, '`updated_on`', 'DESC', false); tpl_assign('messages', $messages); } if (user_config_option('show comments widget')) { $comments = Comments::getSubscriberComments(active_project(), $tag); tpl_assign('comments', $comments); } if (user_config_option('show documents widget') && module_enabled('documents')) { list($documents, $pagination) = ProjectFiles::getProjectFiles(active_project(), null, false, ProjectFiles::ORDER_BY_MODIFYTIME, 'DESC', 1, 10, false, active_tag(), null); tpl_assign('documents', $documents); } if (user_config_option('show emails widget') && module_enabled('email')) { $activeWs = active_project(); list($unread_emails, $pagination) = MailContents::getEmails($tag, null, 'received', 'unread', '', $activeWs, 0, 10); if ($activeWs && user_config_option('always show unread mail in dashboard')) { // add unread unclassified emails list($all_unread, $pagination) = MailContents::getEmails($tag, null, 'received', 'unread', 'unclassified', null, 0, 10); $unread_emails = array_merge($unread_emails, $all_unread); } tpl_assign('unread_emails', $unread_emails); } //Tasks widgets $show_pending = user_config_option('show pending tasks widget') && module_enabled('tasks'); $show_in_progress = user_config_option('show tasks in progress widget') && module_enabled('tasks'); $show_late = user_config_option('show late tasks and milestones widget') && module_enabled('tasks'); if ($show_pending || $show_in_progress || $show_late) { $assigned_to = explode(':', user_config_option('pending tasks widget assigned to filter')); $to_company = array_var($assigned_to, 0, 0); $to_user = array_var($assigned_to, 1, 0); tpl_assign('assigned_to_user_filter', $to_user); tpl_assign('assigned_to_company_filter', $to_company); } if ($show_pending) { $tasks = ProjectTasks::getProjectTasks(active_project(), ProjectTasks::ORDER_BY_DUEDATE, 'ASC', null, null, $tag, $to_company, $to_user, null, true, 'all', false, false, false, 10); tpl_assign('dashtasks', $tasks); } if ($show_in_progress) { $tasks_in_progress = ProjectTasks::getOpenTimeslotTasks(logged_user(), logged_user(), active_project(), $tag, $to_company, $to_user); tpl_assign('tasks_in_progress', $tasks_in_progress); } if ($show_late) { tpl_assign('today_milestones', $logged_user->getTodayMilestones(active_project(), $tag, 10)); tpl_assign('late_milestones', $logged_user->getLateMilestones(active_project(), $tag, 10)); tpl_assign('today_tasks', ProjectTasks::getDayTasksByUser(DateTimeValueLib::now(), $logged_user, active_project(), $tag, $to_company, $to_user, 10)); tpl_assign('late_tasks', ProjectTasks::getLateTasksByUser($logged_user, active_project(), $tag, $to_company, $to_user, 10)); } tpl_assign('activity_log', $activity_log); $usu = logged_user(); $conditions = array("conditions" => array("`state` >= 200 AND (`state`%2 = 0) AND `trashed_by_id`=0 AND `created_by_id` =" . $usu->getId())); $outbox_mails = MailContents::findAll($conditions); if ($outbox_mails != null) { if (count($outbox_mails) == 1) { flash_error(lang('outbox mail not sent', 1)); } else { if (count($outbox_mails) > 1) { flash_error(lang('outbox mails not sent', count($outbox_mails))); } } } ajx_set_no_toolbar(true); }
/** * Show reporting add chart page * * @param void * @return null */ function index() { ajx_set_no_toolbar(true); }
/** * Show company page * * @access public * @param void * @return null */ function company() { if (!can_manage_configuration(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if tpl_assign('company', owner_company()); ajx_set_no_toolbar(true); $this->setTemplate(get_template_path('view_company', 'contact')); }
function copy() { if (logged_user()->isGuest()) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } ajx_set_no_toolbar(); $id = get_id(); $file = ProjectFiles::findById($id); if (!$file instanceof ProjectFile) { flash_error("file dnx"); ajx_current("empty"); return; } if (!$file->canView(logged_user())) { flash_error(lang("no access permissions")); ajx_current("empty"); return; } $original_members = $file->getMembers(); $members = $file->getAllowedMembersToAdd(logged_user(), $original_members); if (!$file->canAdd(logged_user(), $members, $notAllowedMember) ){ if (str_starts_with($notAllowedMember, '-- req dim --')) flash_error(lang('must choose at least one member of', str_replace_first('-- req dim --', '', $notAllowedMember, $in))); else flash_error(lang('no context permissions to add',lang("files"), $notAllowedMember)); ajx_current("empty"); return; } try { DB::beginWork(); $copy = $file->copy(); $copy->setFilename(lang('copy of file', $file->getFilename())); $copy->save(); $copy->addToMembers($members); $copy->addToSharingTable(); $rev_data = array(); $rev_data['name'] = $copy->getFilename(); $rev_data['size'] = $file->getFileSize(); $rev_data['type'] = $file->getTypeString(); $rev_data['tmp_name'] = ROOT . '/tmp/' . rand () ; $handler = fopen($rev_data['tmp_name'], 'w'); $file_content = $file->getLastRevision()->getFileContent(); fputs($handler, $file_content); fclose($handler); $copy->handleUploadedFile($rev_data, false, lang("copied from file", $file->getFilename(), $file->getUniqueObjectId())); DB::commit(); $this->setTemplate('file_details'); tpl_assign('file', $copy); tpl_assign('last_revision', $copy->getLastRevision()); tpl_assign('revisions', $copy->getRevisions()); tpl_assign('order', null); tpl_assign('page', null); ajx_extra_data(array("title" => $copy->getFilename(), 'icon'=>'ico-file')); ajx_set_no_toolbar(true); //read object for this user $copy->setIsRead(logged_user()->getId(),true); ApplicationReadLogs::createLog($copy, ApplicationReadLogs::ACTION_READ); } catch (Exception $ex) { DB::rollback(); flash_error($ex->getMessage()); ajx_current("empty"); } }
/** * View specific email * */ function view() { $this->addHelper('textile'); $email = MailContents::findById(get_id()); if (!$email instanceof MailContent) { flash_error(lang('email dnx')); ajx_current("empty"); return; } if ($email->getIsDeleted()) { flash_error(lang('email dnx deleted')); ajx_current("empty"); return; } if (!$email->canView(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } tpl_assign('email', $email); $attachments = array(); if ($email->getState() >= 200) { $old_memory_limit = ini_get('memory_limit'); if (php_config_value_to_bytes($old_memory_limit) < 256 * 1024 * 1024) { ini_set('memory_limit', '256M'); } $attachments = self::readAttachmentsFromFileSystem($email, $att_ver); if ($attachments && is_array($attachments)) { foreach ($attachments as &$attach) { if ($att_ver < 2) { $attach["FileName"] = $attach['name']; $attach['size'] = format_filesize(strlen($attach["data"])); unset($attach['name']); unset($attach['data']); } else { $attach["FileName"] = $attach['name']; $attach['size'] = format_filesize(filesize($attach["path"])); unset($attach['name']); } } } else { } ini_set('memory_limit', $old_memory_limit); } else { MailUtilities::parseMail($email->getContent(), $decoded, $parsedEmail, $warnings); if (isset($parsedEmail['Attachments'])) { $attachments = $parsedEmail['Attachments']; } foreach ($attachments as &$attach) { $attach['size'] = format_filesize(strlen($attach["Data"])); unset($attach['Data']); } } if ($email->getBodyHtml() != '') { $tmp_folder = "/tmp/" . $email->getAccountId() . "_" . logged_user()->getId() . "_" . $email->getId() . "_temp_mail_content_res"; if (is_dir(ROOT . $tmp_folder)) { remove_dir(ROOT . $tmp_folder); } $parts_array = array_var($decoded, 0, array('Parts' => '')); $email->setBodyHtml(self::rebuild_body_html($email->getBodyHtml(), array_var($parts_array, 'Parts'), $tmp_folder)); } tpl_assign('attachments', $attachments); ajx_extra_data(array("title" => $email->getSubject(), 'icon' => 'ico-email')); ajx_set_no_toolbar(true); if (array_var($_GET, 'replace')) { ajx_replace(true); } $email->setIsRead(logged_user()->getId(), true); ApplicationReadLogs::createLog($email, $email->getWorkspaces(), ApplicationReadLogs::ACTION_READ); }
/** * 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 $task_data = array_var($_POST, 'task'); if (!is_array($task_data)) { $this->getRepeatOptions($task, $occ, $rsel1, $rsel2, $rsel3, $rnum, $rend, $rjump); $tag_names = $task->getTagNames(); $task_data = array('title' => array_var($_POST, 'title', $task->getTitle()), 'text' => $task->getText(), 'milestone_id' => array_var($_POST, 'milestone_id', $task->getMilestoneId()), 'due_date' => getDateValue(array_var($_POST, 'task_due_date'), $task->getDueDate()), 'start_date' => getDateValue(array_var($_POST, 'task_start_date', $task->getStartDate())), 'parent_id' => $task->getParentId(), 'project_id' => array_var($_POST, 'project_id', $task->getProjectId()), 'tags' => is_array($tag_names) && count($tag_names) ? implode(', ', $tag_names) : '', 'is_private' => $task->isPrivate(), 'assigned_to' => array_var($_POST, 'assigned_to', $task->getAssignedToCompanyId() . ':' . $task->getAssignedToUserId()), 'priority' => array_var($_POST, 'priority', $task->getPriority()), 'send_notification' => array_var($_POST, 'notify') == 'true', 'time_estimate' => $task->getTimeEstimate(), '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'))); // array $handins = ObjectHandins::getAllHandinsByObject($task); $id = 0; if ($handins) { foreach ($handins as $handin) { $task_data['handin' . $id] = array('title' => $handin->getTitle(), 'assigned_to' => $handin->getResponsibleCompanyId() . ':' . $handin->getResponsibleUserId()); // array $id = $id + 1; if ($id > 3) { break; } } // foreach } // if } // if tpl_assign('task', $task); tpl_assign('task_data', $task_data); if (is_array(array_var($_POST, 'task'))) { //MANAGE CONCURRENCE WHILE EDITING $upd = array_var($_POST, 'updatedon'); if ($upd && $task->getUpdatedOn()->getTimestamp() > $upd && !array_var($_POST, 'merge-changes') == 'true') { ajx_current('empty'); evt_add("handle edit concurrence", array("updatedon" => $task->getUpdatedOn()->getTimestamp(), "genid" => array_var($_POST, 'genid'))); return; } if (array_var($_POST, 'merge-changes') == 'true') { $this->setTemplate('view_list'); $edited_task = ProjectTasks::findById($task->getId()); ajx_set_no_toolbar(true); ajx_set_panel(lang('tab name', array('name' => $edited_task->getTitle()))); tpl_assign('task_list', $edited_task); ajx_extra_data(array("title" => $edited_task->getTitle(), 'icon' => 'ico-task')); return; } $old_owner = $task->getAssignedTo(); if (array_var($task_data, 'parent_id') == $task->getId()) { flash_error(lang("task own parent error")); ajx_current("empty"); return; } $old_is_private = $task->isPrivate(); $old_project_id = $task->getProjectId(); $project_id = array_var($_POST, 'ws_ids', 0); if ($old_project_id != $project_id) { $newProject = Projects::findById($project_id); if (!$newProject instanceof Project || !$task->canAdd(logged_user(), $newProject)) { flash_error(lang('no access permissions')); 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')); 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; } $was_template = $task->getIsTemplate(); $task->setFromAttributes($task_data); $task->setIsTemplate($was_template); // is_template value must not be changed from ui // Set assigned to $assigned_to = explode(':', array_var($task_data, 'assigned_to', '')); $company_id = array_var($assigned_to, 0, 0); $user_id = array_var($assigned_to, 1, 0); $can_assign = can_assign_task_to_company_user(logged_user(), $task, $company_id, $user_id); if ($can_assign !== true) { flash_error($can_assign); return; } $task->setAssignedToCompanyId($company_id); $task->setAssignedToUserId($user_id); if (!logged_user()->isMemberOfOwnerCompany()) { $task->setIsPrivate($old_is_private); } $totalMinutes = array_var($task_data, 'time_estimate_hours') * 60 + array_var($task_data, 'time_estimate_minutes'); $task->setTimeEstimate($totalMinutes); //Add handins $handins = array(); for ($i = 0; $i < 4; $i++) { if (isset($task_data["handin{$i}"]) && is_array($task_data["handin{$i}"]) && trim(array_var($task_data["handin{$i}"], 'title')) != '') { $assigned_to = explode(':', array_var($task_data["handin{$i}"], 'assigned_to', '')); $handins[] = array('title' => array_var($task_data["handin{$i}"], 'title'), 'responsible_company_id' => array_var($assigned_to, 0, 0), 'responsible_user_id' => array_var($assigned_to, 1, 0)); // array } // if } // for if ($task->getParentId() > 0 && $task->hasChild($task->getParentId())) { flash_error(lang('task child of child error')); ajx_current("empty"); return; } DB::beginWork(); $task->save(); $task->setTagsFromCSV(array_var($task_data, 'tags')); $object_controller = new ObjectController(); $object_controller->add_to_workspaces($task, !$task->getIsTemplate()); $object_controller->link_to_new_object($task); $object_controller->add_subscribers($task); $object_controller->add_custom_properties($task); $object_controller->add_reminders($task); // apply values to subtasks $subtasks = $task->getAllSubTasks(); $project = $task->getProject(); $milestone_id = $task->getMilestoneId(); $apply_ws = array_var($task_data, 'apply_ws_subtasks') == "checked"; $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->getAssignedTo() instanceof ApplicationDataObject) { $sub->setAssignedToCompanyId($company_id); $sub->setAssignedToUserId($user_id); $modified = true; } if ($apply_ws) { $sub->setProject($project); $modified = true; } if ($apply_ms) { $sub->setMilestoneId($milestone_id); $modified = true; } if ($modified) { $sub->save(); } } $task->resetIsRead(); ApplicationLogs::createLog($task, $task->getWorkspaces(), ApplicationLogs::ACTION_EDIT); DB::commit(); try { if (array_var($task_data, 'send_notification') == 'checked') { $new_owner = $task->getAssignedTo(); if ($new_owner instanceof User) { Notifier::taskAssigned($task); } // if } // if } catch (Exception $e) { } // try flash_success(lang('success edit task list', $task->getTitle())); ajx_current("back"); } catch (Exception $e) { DB::rollback(); flash_error($e->getMessage()); ajx_current("empty"); } // try } // if }
/** * Execute search * TODO: Performance gus: * Fetch only ids and execute a select statement by pk (fer each result) * @param void * @return null */ function search() { // Init vars $search_for = array_var($_GET, 'search_for'); $search_dimension = array_var($_GET, 'search_dimension'); $advanced = array_var($_GET, 'advanced'); //$minWordLength = $this->minWordLength($search_for); //$useLike = ( $minWordLength && ($this->ignoreMinWordLength) && ($minWordLength < self::$MYSQL_MIN_WORD_LENGHT) ); $useLike = false; if (strlen($search_for) < 4) { $useLike = true; } $search_pieces = explode(" ", $search_for); $search_string = ""; $search_string = mysql_real_escape_string($search_for, DB::connection()->getLink()); $this->search_for = $search_for; $limit = $this->limit; $start = array_var($_REQUEST, 'start', $this->start); $this->start = $start; $limitTest = max($this->limitTest, $this->limit); $filteredResults = 0; $uid = logged_user()->getId(); if (!isset($search_dimension)) { $members = active_context_members(false); } else { if ($search_dimension == 0) { $members = array(); } else { $members = array($search_dimension); } } // click on search everywhere if (array_var($_REQUEST, 'search_all_projects')) { $members = array(); } $revisionObjectTypeId = ObjectTypes::findByName("file revision")->getId(); $members_sql = ""; if (count($members) > 0) { $context_condition = "(EXISTS\r\n\t\t\t\t\t\t\t\t\t\t(SELECT om.object_id\r\n\t\t\t\t\t\t\t\t\t\t\tFROM " . TABLE_PREFIX . "object_members om\r\n\t\t\t\t\t\t\t\t\t\t\tWHERE\tom.member_id IN (" . implode(',', $members) . ") AND so.rel_object_id = om.object_id\r\n\t\t\t\t\t\t\t\t\t\t\tGROUP BY object_id\r\n\t\t\t\t\t\t\t\t\t\t\tHAVING count(member_id) = " . count($members) . "\r\n\t\t\t\t\t\t\t\t\t\t)\r\n\t\t\t\t\t\t\t\t\t)"; $context_condition_rev = "(EXISTS\r\n\t\t\t\t\t\t\t\t\t\t(SELECT fr.object_id FROM " . TABLE_PREFIX . "object_members om\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "project_file_revisions fr ON om.object_id=fr.file_id\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "objects ob ON fr.object_id=ob.id\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE fr.file_id = so.rel_object_id AND ob.object_type_id = {$revisionObjectTypeId} AND member_id IN (" . implode(',', $members) . ") \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tGROUP BY object_id \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tHAVING count(member_id) = " . count($members) . "\r\n\t\t\t\t\t\t\t\t\t\t)\r\n\t\t\t\t\t\t\t\t\t)"; $members_sql = "AND ( " . $context_condition . " OR " . $context_condition_rev . ")"; $this->search_dimension = implode(',', $members); } else { $this->search_dimension = 0; } $listableObjectTypeIds = implode(",", ObjectTypes::getListableObjectTypeIds()); $can_see_all_tasks_cond = ""; if (!SystemPermissions::userHasSystemPermission(logged_user(), 'can_see_assigned_to_other_tasks')) { $can_see_all_tasks_cond = " AND IF((SELECT ot.name FROM " . TABLE_PREFIX . "object_types ot WHERE ot.id=o.object_type_id)='task',\r\n\t\t\t (SELECT t.assigned_to_contact_id FROM " . TABLE_PREFIX . "project_tasks t WHERE t.object_id=o.id) = " . logged_user()->getId() . ",\r\n\t\t\t true)"; } if ($_POST) { $conditions = array_var($_POST, 'conditions'); $search = array_var($_POST, 'search'); $type_object = array_var($search, 'search_object_type_id'); if (!is_array($conditions)) { $conditions = array(); } $where_condiition = ''; $conditions_view = array(); $cont = 0; $joincp = ""; $value = ""; $custom_prop_id = ""; foreach ($conditions as $condition) { $condValue = array_key_exists('value', $condition) ? $condition['value'] : ''; if ($condition['field_type'] == 'boolean') { $value = array_key_exists('value', $condition); } else { if ($condition['field_type'] == 'date') { if ($condValue != '') { $dtFromWidget = DateTimeValueLib::dateFromFormatAndString(user_config_option('date_format'), $condValue); $value = date("m/d/Y", $dtFromWidget->getTimestamp()); } } else { $value = mysql_real_escape_string($condValue, DB::connection()->getLink()); } } $condition_condition = mysql_real_escape_string(array_var($condition, 'condition'), DB::connection()->getLink()); $condition_field_name = mysql_real_escape_string(array_var($condition, 'field_name'), DB::connection()->getLink()); $conditionLocal = "like"; tpl_assign('type_object', $type_object); //CREO QUE ESTO ESTA MAL if (isset($condition['custom_property_id']) and is_numeric($condition['custom_property_id'])) { $condition_field_name = 'value'; $joincp = 'JOIN ' . TABLE_PREFIX . 'custom_property_values cp ON cp.object_id = so.rel_object_id'; } if ($condition['custom_property_id'] == 'phone_number') { $condition_field_name = 'number'; $joincp = 'JOIN ' . TABLE_PREFIX . 'contact_telephones ct ON ct.contact_id = so.rel_object_id'; } if ($condition['custom_property_id'] == 'email_address') { $condition_field_name = 'email_address'; $joincp = 'JOIN ' . TABLE_PREFIX . 'contact_emails ce ON ce.contact_id = so.rel_object_id'; } if ($condition['custom_property_id'] == 'web_url') { $condition_field_name = 'url'; $joincp = 'JOIN ' . TABLE_PREFIX . 'contact_web_pages cw ON cw.contact_id = so.rel_object_id'; } if ($condition['custom_property_id'] == 'im_value') { $condition_field_name = 'value'; $joincp = 'JOIN ' . TABLE_PREFIX . 'contact_im_values cim ON cim.contact_id = so.rel_object_id'; } if ($condition_condition == "=" or $condition_condition == ">" or $condition_condition == "<" or $condition_condition == "<>" or $condition_condition == ">=" or $condition_condition == "<=") { $conditionLocal = $condition_condition; } if ($condition_field_name == "id") { $condition_field_name = "o`.`id"; } if ($condition_condition == "like") { $where_condiition .= " AND `" . $condition_field_name . "` " . "like" . " '%" . $value . "%' "; $con = "like '%" . $value . "%' "; } else { if ($condition_condition == "ends with") { $where_condiition .= " AND `" . $condition_field_name . "` " . "like" . " '%" . $value . "' "; $con = "like '%" . $value . "' "; } else { if ($condition_condition == "start with") { $where_condiition .= " AND `" . $condition_field_name . "` " . "like" . " '" . $value . "%' "; $con = "like '" . $value . "%' "; } else { if ($condition_condition == "not like") { $where_condiition .= " AND `" . $condition_field_name . "` " . "not like" . " '%" . $value . "%' "; $con = "not like '%" . $value . "%' "; } else { $where_condiition .= " AND `" . $condition_field_name . "` " . $conditionLocal . " '" . $value . "' "; $con = $conditionLocal . " '" . $value . "' "; } } } } if ($condition['custom_property_id'] == 'address') { $addressCondiition .= " AND (street " . $con; $addressCondiition .= " OR city " . $con; $addressCondiition .= " OR state " . $con; $addressCondiition .= " OR country " . $con; $addressCondiition .= " OR zip_code " . $con . ")"; $where_condiition = $addressCondiition; $joincp = 'JOIN ' . TABLE_PREFIX . 'contact_addresses ca ON ca.contact_id = so.rel_object_id'; } $conditions_view[$cont]['id'] = $condition['id']; $conditions_view[$cont]['custom_property_id'] = $custom_prop_id; $conditions_view[$cont]['field_name'] = $condition['field_name']; $conditions_view[$cont]['condition'] = $condition['condition']; $conditions_view[$cont]['value'] = $value; $cont++; } tpl_assign('conditions', $conditions_view); if (empty($conditions)) { $search_string = array_var($search, 'text'); $where_condiition .= " AND so.content LIKE '%{$search_string}%'"; } if ($type_object) { $object_table = ObjectTypes::findById($type_object); $table = $object_table->getTableName(); } $sql = "\r\n\t\t\tSELECT DISTINCT so.rel_object_id AS id\r\n\t\t\tFROM " . TABLE_PREFIX . "searchable_objects so\r\n\t\t\t" . $joincp . "\r\n\t\t\tINNER JOIN " . TABLE_PREFIX . $table . " nto ON nto.object_id = so.rel_object_id \r\n\t\t\tINNER JOIN " . TABLE_PREFIX . "objects o ON o.id = so.rel_object_id \r\n\t\t\tWHERE (\r\n\t\t\t\t(\r\n\t\t\t\t\tEXISTS ( \r\n\t\t\t\t\t\tSELECT object_id FROM " . TABLE_PREFIX . "sharing_table sh\r\n\t\t\t\t\t\tWHERE o.id = sh.object_id \r\n\t\t\t\t\t\tAND sh.group_id IN (\r\n\t\t \t\t\t\t\t\t\t\t\tSELECT permission_group_id FROM " . TABLE_PREFIX . "contact_permission_groups WHERE contact_id = {$uid}\r\n\t\t\t\t\t\t\t\t\t\t\t)\r\n\t\t\t\t\t\t\t)\t\t\t\t\r\n\t\t\t \t)\r\n\t\t\t) " . $where_condiition . $members_sql . $can_see_all_tasks_cond . " ORDER by o.updated_on DESC\r\n\t\t\tLIMIT {$start}, {$limitTest}"; } else { $type_object = ''; $sql = "\t\r\n\t\t\tSELECT DISTINCT so.rel_object_id AS id \r\n\t\t\tFROM " . TABLE_PREFIX . "searchable_objects so\r\n\t\t\tWHERE " . ($useLike ? " so.content LIKE '%{$search_string}%' " : " MATCH (so.content) AGAINST ('\"{$search_string}\"' IN BOOLEAN MODE) ") . " \r\n\t\t\tAND (EXISTS\r\n\t\t\t\t(SELECT o.id\r\n\t\t\t\t FROM " . TABLE_PREFIX . "objects o\r\n\t\t\t\t WHERE\to.id = so.rel_object_id AND (\t\r\n\t\t\t\t\t\t\t(o.object_type_id = {$revisionObjectTypeId} AND \r\n\t\t\t\t\t\t\t\tEXISTS ( \r\n\t\t\t\t\t\t\t\t\tSELECT group_id FROM " . TABLE_PREFIX . "sharing_table WHERE object_id = ( SELECT file_id FROM " . TABLE_PREFIX . "project_file_revisions WHERE object_id = o.id ) \r\n\t\t\t\t\t\t\t\t\tAND group_id IN (SELECT permission_group_id FROM " . TABLE_PREFIX . "contact_permission_groups WHERE contact_id = {$uid} )\r\n\t\t\t\t\t\t\t\t)\r\n\t\t\t\t\t\t\t) \r\n\t\t\t\t\t\t\tOR (\r\n\t\t\t\t\t\t\t\t(EXISTS\r\n\t\t\t\t\t\t\t\t\t(SELECT object_id\r\n\t\t\t\t\t\t\t\t\t\tFROM " . TABLE_PREFIX . "sharing_table sh\r\n\t\t\t\t\t\t\t\t\t\tWHERE o.id = sh.object_id \r\n\t\t\t\t\t\t\t\t\t\tAND sh.group_id IN (\r\n\t\t\t\t\t\t\t\t\t\t\tSELECT permission_group_id FROM " . TABLE_PREFIX . "contact_permission_groups WHERE contact_id = {$uid}\r\n\t\t\t\t\t\t\t\t\t\t)\r\n\t\t\t\t\t\t\t\t\t)\r\n\t\t\t\t\t\t\t\t)\r\n\t\t\t \t\t\t\t)\r\n\t\t\t \t\t) AND o.object_type_id IN ({$listableObjectTypeIds}) " . $members_sql . $can_see_all_tasks_cond . "\r\n\t\t\t\t)\r\n\t\t\t)\t\t\t\r\n\t\t\t\r\n\t\t\tORDER BY id DESC \r\n\t\t\tLIMIT {$start}, {$limitTest}"; } tpl_assign('type_object', $type_object); $db_search_results = array(); $search_results_ids = array(); if (!$advanced) { $timeBegin = time(); $res = DB::execute($sql); $timeEnd = time(); while ($row = $res->fetchRow()) { $search_results_ids[$row['id']] = $row['id']; } } // Prepare results for view to avoid processing at presentation layer $search_results = $this->prepareResults($search_results_ids, $null, $limit); // Calculate or approximate total for pagination $total = count($search_results_ids) + $start; if (count($search_results_ids) < $limitTest) { $total = count($search_results_ids) + $start; } else { $total = lang("many"); } //$total -= $filteredResults ; $this->total = $total; // Pagination $this->buildPagination($search_results, $search_for); // Extra data $extra = new stdClass(); if ($this->showQueryTime) { $extra->time = $timeEnd - $timeBegin; } //$extra->filteredResults = $filteredResults ; // Template asigns tpl_assign('pagination', $this->pagination); tpl_assign('search_string', $search_for); tpl_assign('search_dimension', $this->search_dimension); tpl_assign('search_results', $search_results); tpl_assign('advanced', $advanced); tpl_assign('extra', $extra); $types = array(array("", lang("select one"))); $object_types = ObjectTypes::getAvailableObjectTypes(); foreach ($object_types as $ot) { $types[] = array($ot->getId(), lang($ot->getName())); } // if ($selected_type != '') // tpl_assign('allowed_columns', $this->get_allowed_columns($selected_type)); tpl_assign('object_types', $types); //Ajax if (!$total && !$advanced) { if ($_POST && count($search_results < 0)) { tpl_assign('msg_advanced', true); } else { $this->setTemplate('no_results'); } } ajx_set_no_toolbar(true); }
if (!isset($genid)) { $genid = gen_id(); } set_page_title(lang('edit picture')); $action = $contact->getUpdatePictureUrl(); if (isset($reload_picture) && $reload_picture) { $action .= "&reload_picture={$reload_picture}"; } if (isset($new_contact) && $new_contact) { $action .= "&new_contact={$new_contact}"; } if (array_var($_REQUEST, 'is_company')) { $action .= "&is_company=" . array_var($_REQUEST, 'is_company'); } ajx_set_no_toolbar(); ?> <div class="coInputHeader" style="margin-top:20px;"> <div class="coInputHeaderUpperRow"> <div class="coInputTitle"> <?php echo lang('update avatar'); ?> </div> </div> </div> <table><tr><td> <div id="<?php echo $genid;
/** * View specific email * */ function view() { $this->addHelper('textile'); $email = MailContents::findById(get_id()); if (!$email instanceof MailContent) { flash_error(lang('email dnx')); ajx_current("empty"); return; } if ($email->getIsDeleted()) { flash_error(lang('email dnx deleted')); ajx_current("empty"); return; } if (!$email->canView(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } tpl_assign('email', $email); $additional_body = ""; $attachments = array(); if ($email->getState() >= 200) { $old_memory_limit = ini_get('memory_limit'); if (php_config_value_to_bytes($old_memory_limit) < 256 * 1024 * 1024) { ini_set('memory_limit', '256M'); } $attachments = self::readAttachmentsFromFileSystem($email, $att_ver); if ($attachments && is_array($attachments)) { foreach ($attachments as &$attach) { if ($att_ver < 2) { $attach["FileName"] = $attach['name']; $attach['size'] = format_filesize(strlen($attach["data"])); unset($attach['name']); unset($attach['data']); } else { $attach["FileName"] = $attach['name']; $attach['size'] = format_filesize(filesize($attach["path"])); unset($attach['name']); } } } else { } ini_set('memory_limit', $old_memory_limit); } else { MailUtilities::parseMail($email->getContent(), $decoded, $parsedEmail, $warnings); if (isset($parsedEmail['Attachments'])) { $attachments = $parsedEmail['Attachments']; } else { if ($email->getHasAttachments() && !in_array($parsedEmail['Type'], array('html', 'text', 'delivery-status')) && isset($parsedEmail['FileName'])) { // the email is the attachment $attach = array('Data' => $parsedEmail['Data'], 'Type' => $parsedEmail['Type'], 'FileName' => $parsedEmail['FileName']); $attachments = array($attach); } } $to_remove = array(); foreach ($attachments as $k => &$attach) { // dont show inline images in attachments box if (array_var($attach, 'FileDisposition') == 'inline' && array_var($parsedEmail, 'Type') == 'html') { $attach['hide'] = true; } if (array_var($attach, 'Type') == 'html') { $attach_tmp = $attach['Data']; $attach_tmp = preg_replace('/<html[^>]*[>]/', '', $attach_tmp); $attach_tmp = preg_replace('/<\\/html>/', '', $attach_tmp); $attach_tmp = preg_replace('/<head>*<\\/head>/', '', $attach_tmp); $attach_tmp = preg_replace('/<body[^>]*[>]/', '', $attach_tmp); $attach_tmp = preg_replace('/<\\/body>/', '', $attach_tmp); $additional_body .= $attach_tmp; //break; } $attach['size'] = format_filesize(strlen($attach["Data"])); unset($attach['Data']); } } if ($email->getBodyHtml() != '') { $tmp_folder = "/tmp/" . $email->getAccountId() . "_" . logged_user()->getId() . "_" . $email->getId() . "_temp_mail_content_res"; if (is_dir(ROOT . $tmp_folder)) { remove_dir(ROOT . $tmp_folder); } $parts_array = array_var($decoded, 0, array('Parts' => '')); $email->setBodyHtml(self::rebuild_body_html($email->getBodyHtml(), array_var($parts_array, 'Parts'), $tmp_folder) . $additional_body); } tpl_assign('attachments', $attachments); ajx_extra_data(array("title" => $email->getSubject(), 'icon' => 'ico-email')); ajx_set_no_toolbar(true); if (array_var($_GET, 'replace')) { ajx_replace(true); } if (!$email->getIsRead(logged_user()->getId())) { $object_controler = new ObjectController(); $object_controler->do_mark_as_read_unread_objects(array($email->getId()), true); } ApplicationReadLogs::createLog($email, null, ApplicationReadLogs::ACTION_READ); }
/** * Execute search * TODO: Performance gus: * Fetch only ids and execute a select statement by pk (fer each result) * @param void * @return null */ function search() { // Init vars $search_for = array_var($_GET, 'search_for'); $search_dimension = array_var($_GET, 'search_dimension'); $advanced = array_var($_GET, 'advanced'); $minWordLength = $this->minWordLength($search_for); $useLike = $minWordLength && $this->ignoreMinWordLength && $minWordLength < self::$MYSQL_MIN_WORD_LENGHT; $search_pieces = explode(" ", $search_for); $search_string = ""; if (!$useLike) { // Prepare MATCH AGAINST string foreach ($search_pieces as $word) { if ((strpos($word, "@") || strpos($word, ".") || strpos($word, ",")) === false) { // STRING Dont containt special characheters that mysql use as separator. Noramal flow if ($this->wildCardSearch) { $word .= "*"; } } else { $word = str_replace($this->mysqlWordSeparator, " +", $word); } if (!str_starts_with($word, " ")) { $word = " +" . $word; } $search_string .= mysql_escape_string($word) . " "; } $search_string = substr($search_string, 0, -1); } else { // USE Like Query $search_string = mysql_escape_string($search_for); } $this->search_for = $search_for; $limit = $this->limit; $start = array_var($_REQUEST, 'start', $this->start); $this->start = $start; $limitTest = max($this->limitTest, $this->limit); $filteredResults = 0; $uid = logged_user()->getId(); if (!isset($search_dimension)) { $members = active_context_members(false); } else { if ($search_dimension == 0) { $members = array(); } else { $members = array($search_dimension); } } $members_sql = ""; if (count($members) > 0) { $members_sql = "AND rel_object_id IN (SELECT object_id FROM " . TABLE_PREFIX . "object_members om WHERE member_id IN (" . implode(',', $members) . ") \n GROUP BY object_id\n HAVING count(member_id) = " . count($members) . ")"; $this->search_dimension = implode(',', $members); } else { $this->search_dimension = 0; } $revisionObjectTypeId = ObjectTypes::findByName("file revision")->getId(); $listableObjectTypeIds = implode(",", ObjectTypes::getListableObjectTypeIds()); if ($_POST) { $conditions = array_var($_POST, 'conditions'); $search = array_var($_POST, 'search'); $type_object = array_var($search, 'search_object_type_id'); if (!is_array($conditions)) { $conditions = array(); } $where_condiition = ''; $conditions_view = array(); $cont = 0; foreach ($conditions as $condition) { $condValue = array_key_exists('value', $condition) ? $condition['value'] : ''; if ($condition['field_type'] == 'boolean') { $value = array_key_exists('value', $condition); } else { if ($condition['field_type'] == 'date') { if ($condValue != '') { $dtFromWidget = DateTimeValueLib::dateFromFormatAndString(user_config_option('date_format'), $condValue); $value = date("m/d/Y", $dtFromWidget->getTimestamp()); } } else { $value = $condValue; } } if ($condition['condition'] == "like") { $where_condiition .= " AND " . $condition['field_name'] . " " . $condition['condition'] . " '" . $value . "%' "; } else { $where_condiition .= " AND " . $condition['field_name'] . " " . $condition['condition'] . " '" . $value . "' "; } $conditions_view[$cont]['id'] = $condition['id']; $conditions_view[$cont]['custom_property_id'] = $condition['custom_property_id']; $conditions_view[$cont]['field_name'] = $condition['field_name']; $conditions_view[$cont]['condition'] = $condition['condition']; $conditions_view[$cont]['value'] = $value; $cont++; } tpl_assign('conditions', $conditions_view); if ($type_object) { $object_table = ObjectTypes::findById($type_object); $table = $object_table->getTableName(); } $sql = "\t\n\t\t\tSELECT distinct(so.rel_object_id) AS id\n\t\t\tFROM " . TABLE_PREFIX . "searchable_objects so\n INNER JOIN " . TABLE_PREFIX . $table . " nto ON nto.object_id = so.rel_object_id \n\t\t\tINNER JOIN " . TABLE_PREFIX . "objects o ON o.id = so.rel_object_id \n\t\t\tWHERE (\n\t\t\t\t(\n\t\t\t\t\tso.rel_object_id IN (\n\t\t\t \t\tSELECT object_id FROM " . TABLE_PREFIX . "sharing_table WHERE group_id IN (\n\t\t\t \t\t\tSELECT permission_group_id FROM " . TABLE_PREFIX . "contact_permission_groups WHERE contact_id = {$uid}\n\t\t\t \t\t)\n\t\t\t \t\t)\n\t\t\t \t)\n\t\t\t) " . $where_condiition . $members_sql . " ORDER by o.updated_on DESC\n\t\t\tLIMIT {$start}, {$limitTest} "; } else { $type_object = ''; $sql = "\t\n\t\t\tSELECT distinct(so.rel_object_id) AS id\n\t\t\tFROM " . TABLE_PREFIX . "searchable_objects so\n\t\t\tINNER JOIN " . TABLE_PREFIX . "objects o ON o.id = so.rel_object_id \n\t\t\tWHERE (\n\t\t\t\t(\t\n\t\t\t\t\to.object_type_id = {$revisionObjectTypeId} AND \n\t\t\t\t\tEXISTS ( \n\t\t\t\t\t\tSELECT id FROM " . TABLE_PREFIX . "sharing_table WHERE object_id = ( SELECT file_id FROM " . TABLE_PREFIX . "project_file_revisions WHERE object_id = o.id ) \n\t\t\t\t\t\tAND group_id IN (SELECT permission_group_id FROM " . TABLE_PREFIX . "contact_permission_groups WHERE contact_id = {$uid} )\n\t\t\t\t\t)\n\t\t\t\t\t\n\t\t\t\t) \n\t\t\t\tOR (\n\t\t\t\t\tso.rel_object_id IN (\n\t\t\t \t\tSELECT object_id FROM " . TABLE_PREFIX . "sharing_table WHERE group_id IN (\n\t\t\t \t\t\tSELECT permission_group_id FROM " . TABLE_PREFIX . "contact_permission_groups WHERE contact_id = {$uid}\n\t\t\t \t\t)\n\t\t\t \t\t)\n\t\t\t \t)\n\t\t\t)" . ($useLike ? "AND\tso.content LIKE '%{$search_string}%' " : "AND MATCH (so.content) AGAINST ('{$search_string}' IN BOOLEAN MODE) ") . " \n\t\t\tAND o.object_type_id IN ({$listableObjectTypeIds}) \n " . $members_sql . "\n\t\t\tORDER by o.updated_on DESC\n\t\t\tLIMIT {$start}, {$limitTest} "; } tpl_assign('type_object', $type_object); $db_search_results = array(); $search_results_ids = array(); $timeBegin = time(); $res = DB::execute($sql); $timeEnd = time(); if ($this->debug) { alert_r("<br>SQL:<br>" . $sql . "<hr>TIME:" . ($timeEnd - $timeBegin)); } while ($row = $res->fetchRow()) { $search_results_ids[] = $row['id']; } // Prepare results for view to avoid processing at presentation layer $search_results = $this->prepareResults($search_results_ids, $null, $limit); // Calculate or approximate total for pagination $total = count($search_results_ids) + $start; if (count($search_results_ids) < $limitTest) { $total = count($search_results_ids) + $start; } else { $total = "Many"; } //$total -= $filteredResults ; $this->total = $total; // Pagination $this->buildPagination($search_results); // Extra data $extra = new stdClass(); if ($this->showQueryTime) { $extra->time = $timeEnd - $timeBegin; } //$extra->filteredResults = $filteredResults ; // Template asigns tpl_assign('pagination', $this->pagination); tpl_assign('search_string', $search_for); tpl_assign('search_dimension', $this->search_dimension); tpl_assign('search_results', $search_results); tpl_assign('advanced', $advanced); tpl_assign('extra', $extra); $types = array(array("", lang("select one"))); $object_types = ObjectTypes::getAvailableObjectTypes(); foreach ($object_types as $ot) { $types[] = array($ot->getId(), lang($ot->getName())); } // if ($selected_type != '') // tpl_assign('allowed_columns', $this->get_allowed_columns($selected_type)); tpl_assign('object_types', $types); // //Ajax if (!$total && !$advanced) { if ($_POST && count($search_results < 0)) { tpl_assign('msg_advanced', true); } else { $this->setTemplate('no_results'); } } ajx_set_no_toolbar(true); }
function edit() { if (logged_user()->isGuest()) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $this->setTemplate('event'); $event = ProjectEvents::findById(get_id()); $user_filter = isset($_GET['user_id']) ? $_GET['user_id'] : logged_user()->getId(); $inv = EventInvitations::findById(array('event_id' => $event->getId(), 'user_id' => $user_filter)); if ($inv != null) { $event->addInvitation($inv); } if (!$event->canEdit(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } tpl_assign('active_projects', logged_user()->getActiveProjects()); $event_data = array_var($_POST, 'event'); if (!is_array($event_data)) { $tag_names = $event->getTagNames(); $setlastweek = false; $rsel1 = false; $rsel2 = false; $rsel3 = false; $forever = $event->getRepeatForever(); $occ = 1; if ($event->getRepeatD() > 0) { $occ = 2; $rjump = $event->getRepeatD(); } if ($event->getRepeatD() > 0 and $event->getRepeatD() % 7 == 0) { $occ = 3; $rjump = $event->getRepeatD() / 7; } if ($event->getRepeatM() > 0) { $occ = 4; $rjump = $event->getRepeatM(); } if ($event->getRepeatY() > 0) { $occ = 5; $rjump = $event->getRepeatY(); } if ($event->getRepeatH() > 0) { $occ = 6; } if ($event->getRepeatH() == 2) { $setlastweek = true; } if ($event->getRepeatEnd()) { $rend = $event->getRepeatEnd(); } if ($event->getRepeatNum() > 0) { $rnum = $event->getRepeatNum(); } if (!isset($rjump) || !is_numeric($rjump)) { $rjump = 1; } // decide which repeat type it is if ($forever) { $rsel1 = true; } else { if (isset($rnum) and $rnum > 0) { $rsel2 = true; } else { if (isset($rend) and $rend instanceof DateTimeValue) { $rsel3 = true; } } } //repeat until //if(isset($rend) AND $rend=="9999-00-00") $rend = ""; // organize the time and date data for the html select drop downs. $thetime = $event->getStart()->getTimestamp() + logged_user()->getTimezone() * 3600; $durtime = $event->getDuration()->getTimestamp() + logged_user()->getTimezone() * 3600 - $thetime; $hour = date('G', $thetime); // format time to 24-hour or 12-hour clock. if (!user_config_option('time_format_use_24')) { if ($hour >= 12) { $pm = 1; $hour = $hour - 12; } else { $pm = 0; } } $event_data = array('subject' => $event->getSubject(), 'description' => $event->getDescription(), 'name' => $event->getCreatedById(), 'username' => $event->getCreatedById(), 'typeofevent' => $event->getTypeId(), 'forever' => $event->getRepeatForever(), 'usetimeandduration' => $event->getTypeId() == 3 ? 0 : 1, 'occ' => $occ, 'rjump' => $rjump, 'setlastweek' => $setlastweek, 'rend' => isset($rend) ? $rend : NULL, 'rnum' => isset($rnum) ? $rnum : NULL, 'rsel1' => $rsel1, 'rsel2' => $rsel2, 'rsel3' => $rsel3, 'thetime' => $event->getStart()->getTimestamp(), 'hour' => $hour, 'minute' => date('i', $thetime), 'month' => date('n', $thetime), 'year' => date('Y', $thetime), 'day' => date('j', $thetime), 'durtime' => $event->getDuration()->getTimestamp() - $thetime, 'durationmin' => $durtime / 60 % 60, 'durationhour' => $durtime / 3600 % 24, 'durday' => floor($durtime / 86400), 'pm' => isset($pm) ? $pm : 0, 'tags' => is_array($tag_names) ? implode(', ', $tag_names) : '', 'repeat_dow' => $event->getRepeatDow(), 'repeat_wnum' => $event->getRepeatWnum(), 'repeat_mjump' => $event->getRepeatMjump()); // array } // if tpl_assign('event_data', $event_data); tpl_assign('event', $event); if (is_array(array_var($_POST, 'event'))) { // MANAGE CONCURRENCE WHILE EDITING $upd = array_var($_POST, 'updatedon'); if ($upd && $event->getUpdatedOn()->getTimestamp() > $upd && !array_var($_POST, 'merge-changes') == 'true') { ajx_current('empty'); evt_add("handle edit concurrence", array("updatedon" => $event->getUpdatedOn()->getTimestamp(), "genid" => array_var($_POST, 'genid'))); return; } if (array_var($_POST, 'merge-changes') == 'true') { $this->setTemplate('view_event'); $editedEvent = ProjectEvents::findById($event->getId()); $this->viewevent(); ajx_set_panel(lang('tab name', array('name' => $editedEvent->getTitle()))); ajx_extra_data(array("title" => $editedEvent->getTitle(), 'icon' => 'ico-event')); ajx_set_no_toolbar(true); ajx_set_panel(lang('tab name', array('name' => $editedEvent->getTitle()))); return; } try { $data = $this->getData($event_data); // run the query to set the event data $event->setFromAttributes($data); $this->registerInvitations($data, $event, false); if (isset($data['confirmAttendance'])) { $this->change_invitation_state($data['confirmAttendance'], $event->getId(), $user_filter); } if (isset($data['send_notification']) && $data['send_notification']) { $users_to_inv = array(); foreach ($data['users_to_invite'] as $us => $v) { if ($us != logged_user()->getId()) { $users_to_inv[] = Users::findById(array('id' => $us)); } } Notifier::notifEvent($event, $users_to_inv, 'modified', logged_user()); } foreach ($data['users_to_invite'] as $user_id => $v) { $user = Users::findById(array('id' => $user_id)); if ($user instanceof User) { $phone_num = Users::getPhoneNumberCustomProperty($user_id); $sms_obj = new SmsController(); $sms_obj->prepareEventInvitee($user->getDisplayName(), $event->getTitle(), get_class($event)); $sms_obj->sendSms($phone_num); } } if (!logged_user()->isMemberOfOwnerCompany()) { $event->setIsPrivate(false); } DB::beginWork(); $event->save(); $event->setTagsFromCSV(array_var($event_data, 'tags')); $object_controller = new ObjectController(); $object_controller->add_to_workspaces($event); $object_controller->link_to_new_object($event); $object_controller->add_subscribers($event); $object_controller->add_custom_properties($event); $object_controller->add_reminders($event); $event->resetIsRead(); ApplicationLogs::createLog($event, $event->getWorkspaces(), ApplicationLogs::ACTION_EDIT); DB::commit(); flash_success(lang('success edit event', clean($event->getObjectName()))); if (array_var($_POST, 'popup', false)) { ajx_current("reload"); } else { ajx_current("back"); } ajx_add("overview-panel", "reload"); } catch (Exception $e) { DB::rollback(); flash_error($e->getMessage()); ajx_current("empty"); //tpl_assign('error', $e); } // try } // if }
function contracted_services() { ajx_set_no_toolbar(); }
/** * Execute search * TODO: Performance gus: * Fetch only ids and execute a select statement by pk (fer each result) * @param void * @return null */ function search() { // Init vars $search_for = array_var($_GET, 'search_for'); $search_dimension = array_var($_GET, 'search_dimension'); $advanced = array_var($_GET, 'advanced'); $minWordLength = $this->minWordLength($search_for); $useLike = ( $minWordLength && ($this->ignoreMinWordLength) && ($minWordLength < self::$MYSQL_MIN_WORD_LENGHT) ); $search_pieces= explode(" ", $search_for); $search_string = ""; if (!$useLike){ // Prepare MATCH AGAINST string foreach ($search_pieces as $word ) { if (( strpos($word, "@") || strpos($word, ".") || strpos($word, ",")) === false ) { // STRING Dont containt special characheters that mysql use as separator. Noramal flow if ($this->wildCardSearch) { $word.="*"; } }else{ $word = str_replace($this->mysqlWordSeparator, " +", $word) ; } if ( !str_starts_with($word, " ") ) { $word = " +".$word; } $search_string .= mysql_real_escape_string( $word ). " "; } $search_string = substr($search_string, 0 , -1); }else{ // USE Like Query $search_string = mysql_real_escape_string($search_for, DB::connection()->getLink()); } $this->search_for = $search_for; $limit = $this->limit; $start = array_var($_REQUEST, 'start' , $this->start); $this->start = $start; $limitTest = max( $this->limitTest , $this->limit); $filteredResults = 0; $uid = logged_user()->getId(); if(!isset($search_dimension)){ $members = active_context_members(false); }else{ if($search_dimension == 0){ $members = array(); }else{ $members = array($search_dimension); } } // click on search everywhere if (array_var($_REQUEST, 'search_all_projects')) { $members = array(); } $revisionObjectTypeId = ObjectTypes::findByName("file revision")->getId(); $members_sql = ""; if(count($members) > 0){ $members_sql = "AND (rel_object_id IN (SELECT object_id FROM " . TABLE_PREFIX . "object_members om WHERE member_id IN (" . implode ( ',', $members ) . ") GROUP BY object_id HAVING count(member_id) = ".count($members).") OR o.object_type_id = $revisionObjectTypeId AND rel_object_id IN (SELECT fr.object_id FROM " . TABLE_PREFIX . "object_members om INNER JOIN ".TABLE_PREFIX."project_file_revisions fr ON om.object_id=fr.file_id WHERE member_id IN (" . implode ( ',', $members ) . ") GROUP BY object_id HAVING count(member_id) = ".count($members)."))"; $this->search_dimension = implode ( ',', $members ); }else{ $this->search_dimension = 0; } $listableObjectTypeIds = implode(",",ObjectTypes::getListableObjectTypeIds()); if($_POST) { $conditions = array_var($_POST, 'conditions'); $search = array_var($_POST, 'search'); $type_object = array_var($search, 'search_object_type_id'); if(!is_array($conditions)) $conditions = array(); $where_condiition = ''; $conditions_view = array(); $cont = 0; $joincp =""; foreach($conditions as $condition){ $condValue = array_key_exists('value', $condition) ? $condition['value'] : ''; if($condition['field_type'] == 'boolean'){ $value = array_key_exists('value', $condition); }else if($condition['field_type'] == 'date'){ if ($condValue != '') { $dtFromWidget = DateTimeValueLib::dateFromFormatAndString(user_config_option('date_format'), $condValue); $value = date("m/d/Y", $dtFromWidget->getTimestamp()); } }else{ $value = mysql_real_escape_string($condValue, DB::connection()->getLink()); } $condition_condition = mysql_real_escape_string(array_var($condition, 'condition'), DB::connection()->getLink()); $condition_field_name = mysql_real_escape_string(array_var($condition, 'field_name'), DB::connection()->getLink()); $conditionLocal = "like"; tpl_assign('type_object', $type_object); if (isset($condition['custom_property_id']) and is_numeric($condition['custom_property_id'])){ $condition_field_name = 'value'; $joincp = 'JOIN fo_custom_property_values cp ON cp.object_id = so.rel_object_id'; }; if ($condition_condition == "=" or $condition_condition == ">" or $condition_condition == "<" or $condition_condition == "<>" or $condition_condition == ">=" or $condition_condition == "<="){ $conditionLocal = $condition_condition; }; if($condition_field_name == "id"){ $condition_field_name = "o`.`id" ; }; if($condition_condition == "like"){ $where_condiition .= " AND `" . $condition_field_name . "` " . "like" . " '%" . $value . "%' "; }else if($condition_condition == "ends with"){ $where_condiition .= " AND `" . $condition_field_name . "` " . "like" . " '%" . $value . "' "; }else if($condition_condition == "start with"){ $where_condiition .= " AND `" . $condition_field_name . "` " . "like" . " '" . $value . "%' "; }else if($condition_condition == "not like"){ $where_condiition .= " AND `" . $condition_field_name . "` " . "not like" . " '%" . $value . "%' "; }else{ $where_condiition .= " AND `" . $condition_field_name . "` " . $conditionLocal . " '" . $value . "' "; } $conditions_view[$cont]['id'] = $condition['id']; $conditions_view[$cont]['custom_property_id'] = $custom_prop_id; $conditions_view[$cont]['field_name'] = $condition['field_name']; $conditions_view[$cont]['condition'] = $condition['condition']; $conditions_view[$cont]['value'] = $value; $cont++; } tpl_assign('conditions', $conditions_view); if($type_object){ $object_table = ObjectTypes::findById($type_object); $table = $object_table->getTableName(); } $sql = " SELECT distinct(so.rel_object_id) AS id FROM ".TABLE_PREFIX."searchable_objects so ".$joincp." INNER JOIN ".TABLE_PREFIX.$table." nto ON nto.object_id = so.rel_object_id INNER JOIN ".TABLE_PREFIX."objects o ON o.id = so.rel_object_id WHERE ( ( so.rel_object_id IN ( SELECT object_id FROM ".TABLE_PREFIX."sharing_table WHERE group_id IN ( SELECT permission_group_id FROM ".TABLE_PREFIX."contact_permission_groups WHERE contact_id = $uid ) ) ) ) " . $where_condiition . $members_sql . " ORDER by o.updated_on DESC LIMIT $start, $limitTest "; } else { $type_object = ''; $sql = " SELECT distinct(so.rel_object_id) AS id FROM ".TABLE_PREFIX."searchable_objects so INNER JOIN ".TABLE_PREFIX."objects o ON o.id = so.rel_object_id WHERE ( ( o.object_type_id = $revisionObjectTypeId AND EXISTS ( SELECT id FROM ".TABLE_PREFIX."sharing_table WHERE object_id = ( SELECT file_id FROM ".TABLE_PREFIX."project_file_revisions WHERE object_id = o.id ) AND group_id IN (SELECT permission_group_id FROM ".TABLE_PREFIX."contact_permission_groups WHERE contact_id = $uid ) ) ) OR ( so.rel_object_id IN ( SELECT object_id FROM ".TABLE_PREFIX."sharing_table WHERE group_id IN ( SELECT permission_group_id FROM ".TABLE_PREFIX."contact_permission_groups WHERE contact_id = $uid ) ) ) )" . (($useLike) ? "AND so.content LIKE '%$search_string%' " : "AND MATCH (so.content) AGAINST ('$search_string' IN BOOLEAN MODE) ") . " AND o.object_type_id IN ($listableObjectTypeIds) " . $members_sql . " ORDER by o.updated_on DESC LIMIT $start, $limitTest "; } tpl_assign('type_object', $type_object); $db_search_results = array(); $search_results_ids = array(); $timeBegin = time(); $res = DB::execute($sql); $timeEnd = time(); while ($row = $res->fetchRow() ) { $search_results_ids[] = $row['id'] ; } // Prepare results for view to avoid processing at presentation layer $search_results = $this->prepareResults($search_results_ids, $null, $limit); // Calculate or approximate total for pagination $total = count($search_results_ids) + $start ; if ( count ( $search_results_ids ) < $limitTest ) { $total = count($search_results_ids) + $start ; }else{ $total = "Many" ; } //$total -= $filteredResults ; $this->total = $total ; // Pagination $this->buildPagination($search_results, $search_for); // Extra data $extra = new stdClass() ; if ($this->showQueryTime) { $extra->time = $timeEnd-$timeBegin ; } //$extra->filteredResults = $filteredResults ; // Template asigns tpl_assign('pagination', $this->pagination); tpl_assign('search_string', $search_for); tpl_assign('search_dimension', $this->search_dimension); tpl_assign('search_results', $search_results); tpl_assign('advanced', $advanced); tpl_assign('extra', $extra ); $types = array(array("", lang("select one"))); $object_types = ObjectTypes::getAvailableObjectTypes(); foreach ($object_types as $ot) { $types[] = array($ot->getId(), lang($ot->getName())); } // if ($selected_type != '') // tpl_assign('allowed_columns', $this->get_allowed_columns($selected_type)); tpl_assign('object_types', $types); //Ajax if (!$total && !$advanced){ if($_POST && count($search_results < 0)){ tpl_assign('msg_advanced', true); }else{ $this->setTemplate('no_results'); } } ajx_set_no_toolbar(true); }
function view() { if (!can_manage_templates(logged_user())) { flash_error(lang("no access permissions")); ajx_current("empty"); return; } $cotemplate = COTemplates::findById(get_id()); if (!$cotemplate instanceof COTemplate) { flash_error(lang('template dnx')); ajx_current("empty"); return; } // if if (!$cotemplate->canView(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if tpl_assign('cotemplate', $cotemplate); ajx_set_no_toolbar(true); ApplicationReadLogs::createLog($cotemplate, ApplicationReadLogs::ACTION_READ); }
/** * Edit specific message * * @access public * @param void * @return null */ function edit() { $this->setTemplate('add_message'); if (logged_user()->isGuest()) { flash_error(lang('no access permissions')); ajx_current('empty'); return; } $message = ProjectMessages::findById(get_id()); if (!$message instanceof ProjectMessage) { flash_error(lang('message dnx')); ajx_current("empty"); return; } // if if (!$message->canEdit(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if $message_data = array_var($_POST, 'message'); if (!is_array($message_data)) { $tag_names = $message->getTagNames(); $message_data = array('milestone_id' => $message->getMilestoneId(), 'title' => $message->getTitle(), 'text' => $message->getText(), 'additional_text' => $message->getAdditionalText(), 'tags' => is_array($tag_names) ? implode(', ', $tag_names) : '', 'is_private' => $message->isPrivate(), 'is_important' => $message->getIsImportant(), 'comments_enabled' => $message->getCommentsEnabled(), 'anonymous_comments_enabled' => $message->getAnonymousCommentsEnabled()); // array } // if tpl_assign('message', $message); tpl_assign('message_data', $message_data); if (is_array(array_var($_POST, 'message'))) { try { //MANAGE CONCURRENCE WHILE EDITING $upd = array_var($_POST, 'updatedon'); if ($upd && $message->getUpdatedOn()->getTimestamp() > $upd && !array_var($_POST, 'merge-changes') == 'true') { ajx_current('empty'); evt_add("handle edit concurrence", array("updatedon" => $message->getUpdatedOn()->getTimestamp(), "genid" => array_var($_POST, 'genid'))); return; } if (array_var($_POST, 'merge-changes') == 'true') { $this->setTemplate('view'); $edited_note = ProjectMessages::findById($message->getId()); tpl_assign('message', $edited_note); tpl_assign('subscribers', $edited_note->getSubscribers()); ajx_extra_data(array("title" => $edited_note->getTitle(), 'icon' => 'ico-message')); ajx_set_no_toolbar(true); ajx_set_panel(lang('tab name', array('name' => $edited_note->getTitle()))); return; } $old_is_private = $message->isPrivate(); $old_is_important = $message->getIsImportant(); $old_comments_enabled = $message->getCommentsEnabled(); $old_anonymous_comments_enabled = $message->getAnonymousCommentsEnabled(); $message->setFromAttributes($message_data); // Options are reserved only for members of owner company if (!logged_user()->isMemberOfOwnerCompany()) { $message->setIsPrivate($old_is_private); $message->setIsImportant($old_is_important); $message->setCommentsEnabled($old_comments_enabled); $message->setAnonymousCommentsEnabled($old_anonymous_comments_enabled); } // if DB::beginWork(); $message->save(); $message->setTagsFromCSV(array_var($message_data, 'tags')); $object_controller = new ObjectController(); $object_controller->add_to_workspaces($message); $object_controller->link_to_new_object($message); $object_controller->add_subscribers($message); $object_controller->add_custom_properties($message); $message->resetIsRead(); ApplicationLogs::createLog($message, $message->getWorkspaces(), ApplicationLogs::ACTION_EDIT); DB::commit(); flash_success(lang('success edit message', $message->getTitle())); if (array_var($_POST, 'popup', false)) { ajx_current("reload"); } else { ajx_current("back"); } } catch (Exception $e) { DB::rollback(); flash_error($e->getMessage()); ajx_current("empty"); } // try } // if }
function copy() { if (logged_user()->isGuest()) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } ajx_set_no_toolbar(); $ws = active_or_personal_project(); $id = get_id(); $file = ProjectFiles::findById($id); if (!$file instanceof ProjectFile) { flash_error("file dnx"); ajx_current("empty"); return; } if (!can_read(logged_user(), $file)) { flash_error("no access permissions"); ajx_current("empty"); return; } if (!ProjectFile::canAdd(logged_user(), $ws)) { flash_error("no access permissions"); ajx_current("empty"); return; } try { DB::beginWork(); $copy = $file->copy(); $copy->setFilename(lang('copy of file', $file->getFilename())); $copy->save(); $copy->addToWorkspace($ws); $rev_data = array(); $rev_data['name'] = $copy->getFilename(); $rev_data['size'] = $file->getFileSize(); $rev_data['type'] = $file->getTypeString(); $rev_data['tmp_name'] = ROOT . '/tmp/' . rand(); $handler = fopen($rev_data['tmp_name'], 'w'); $file_content = $file->getLastRevision()->getFileContent(); fputs($handler, $file_content); fclose($handler); $copy->handleUploadedFile($rev_data, false, lang("copied from file", $file->getFilename(), $file->getUniqueObjectId())); DB::commit(); $this->setTemplate('file_details'); tpl_assign('file', $copy); tpl_assign('last_revision', $copy->getLastRevision()); tpl_assign('revisions', $copy->getRevisions()); } catch (Exception $ex) { DB::rollback(); flash_error($ex->getMessage()); ajx_current("empty"); } }
function index() { $tasksUserId = array_var($_GET, 'tu'); if (is_null($tasksUserId)) { $tasksUserId = user_config_option('TM tasks user filter', logged_user()->getId()); } else { if (user_config_option('TM tasks user filter') != $tasksUserId) { set_user_config_option('TM tasks user filter', $tasksUserId, logged_user()->getId()); } } $timeslotsUserId = array_var($_GET, 'tsu'); if (is_null($timeslotsUserId)) { $timeslotsUserId = user_config_option('TM user filter', 0); } else { if (user_config_option('TM user filter') != $timeslotsUserId) { set_user_config_option('TM user filter', $timeslotsUserId, logged_user()->getId()); } } $showTimeType = array_var($_GET, 'stt'); if (is_null($showTimeType)) { $showTimeType = user_config_option('TM show time type', 0); } else { if (user_config_option('TM show time type') != $showTimeType) { set_user_config_option('TM show time type', $showTimeType, logged_user()->getId()); } } $start = array_var($_GET, 'start', 0); $limit = 20; $tasksUser = Contacts::findById($tasksUserId); $timeslotsUser = Contacts::findById($timeslotsUserId); //Active tasks view $open_timeslots = Timeslots::instance()->listing(array("extra_conditions" => " AND end_time = '" . EMPTY_DATETIME . "' AND contact_id = " . $tasksUserId))->objects; $tasks = array(); foreach ($open_timeslots as $open_timeslot) { $task = ProjectTasks::findById($open_timeslot->getRelObjectId()); if ($task instanceof ProjectTask && !$task->isCompleted() && !$task->isTrashed() && !$task->isArchived()) { $tasks[] = $task; } } ProjectTasks::populateTimeslots($tasks); //Timeslots view $total = 0; switch ($showTimeType) { case 0: //Show only timeslots added through the time panel $result = Timeslots::getGeneralTimeslots(active_context(), $timeslotsUser, $start, $limit); $timeslots = $result->objects; $total = $result->total; break; default: throw new Error('Unrecognised TM show time type: ' . $showTimeType); } //Get Users Info $users = array(); $context = active_context(); if (!can_manage_time(logged_user())) { if (can_add(logged_user(), $context, Timeslots::instance()->getObjectTypeId())) { $users = array(logged_user()); } } else { if (logged_user()->isMemberOfOwnerCompany()) { $users = Contacts::getAllUsers(); } else { $users = logged_user()->getCompanyId() > 0 ? Contacts::getAllUsers(" AND `company_id` = " . logged_user()->getCompanyId()) : array(logged_user()); } $tmp_users = array(); foreach ($users as $user) { if (can_add($user, $context, Timeslots::instance()->getObjectTypeId())) { $tmp_users[] = $user; } } $users = $tmp_users; } //Get Companies Info if (logged_user()->isMemberOfOwnerCompany() || logged_user()->isAdminGroup()) { $companies = Contacts::getCompaniesWithUsers(); } else { $companies = array(); if (logged_user()->getCompanyId() > 0) { $companies[] = logged_user()->getCompany(); } } $required_dimensions = DimensionObjectTypeContents::getRequiredDimensions(Timeslots::instance()->getObjectTypeId()); $draw_inputs = !$required_dimensions || count($required_dimensions) == 0; if (!$draw_inputs) { $ts_ots = DimensionObjectTypeContents::getDimensionObjectTypesforObject(Timeslots::instance()->getObjectTypeId()); $context = active_context(); foreach ($context as $sel) { if ($sel instanceof Member) { foreach ($ts_ots as $ts_ot) { if ($sel->getDimensionId() == $ts_ot->getDimensionId() && $sel->getObjectTypeId() == $ts_ot->getDimensionObjectTypeId()) { $draw_inputs = true; break; } } if ($draw_inputs) { break; } } } } tpl_assign('draw_inputs', $draw_inputs); tpl_assign('selected_user', logged_user()->getId()); tpl_assign('timeslots', $timeslots); tpl_assign('tasks', $tasks); if (count($tasks) > 0) { tpl_assign('all_users', Contacts::getAllUsers()); } tpl_assign('users', $users); tpl_assign('start', $start); tpl_assign('limit', $limit); tpl_assign('total', $total); tpl_assign('companies', $companies); ajx_set_no_toolbar(true); }
/** * View single message * * @access public * @param void * @return null */ function view() { $this->addHelper('textile'); $message = ProjectMessages::findById(get_id()); if (!$message instanceof ProjectMessage) { flash_error(lang('message dnx')); ajx_current("empty"); return; } // if if (!$message->canView(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if $this->setHelp("view_message"); //read object for this user $message->setIsRead(logged_user()->getId(), true); tpl_assign('message', $message); tpl_assign('subscribers', $message->getSubscribers()); ajx_extra_data(array("title" => $message->getTitle(), 'icon' => $message->getIconClass())); ajx_set_no_toolbar(true); ApplicationReadLogs::createLog($message, ApplicationReadLogs::ACTION_READ); }
function index() { if (!can_manage_time(logged_user(), true)) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $tasksUserId = array_var($_GET, 'tu'); if (is_null($tasksUserId)) { $tasksUserId = user_config_option('TM tasks user filter', logged_user()->getId()); } else { if (user_config_option('TM tasks user filter') != $tasksUserId) { set_user_config_option('TM tasks user filter', $tasksUserId, logged_user()->getId()); } } $timeslotsUserId = array_var($_GET, 'tsu'); if (is_null($timeslotsUserId)) { $timeslotsUserId = user_config_option('TM user filter', 0); } else { if (user_config_option('TM user filter') != $timeslotsUserId) { set_user_config_option('TM user filter', $timeslotsUserId, logged_user()->getId()); } } $showTimeType = array_var($_GET, 'stt'); if (is_null($showTimeType)) { $showTimeType = user_config_option('TM show time type', 0); } else { if (user_config_option('TM show time type') != $showTimeType) { set_user_config_option('TM show time type', $showTimeType, logged_user()->getId()); } } $start = array_var($_GET, 'start', 0); $limit = 20; $tasksUser = Users::findById($tasksUserId); $timeslotsUser = Users::findById($timeslotsUserId); //Active tasks view $tasks = ProjectTasks::getOpenTimeslotTasks($tasksUser, logged_user()); ProjectTasks::populateData($tasks); $tasks_array = array(); //Timeslots view $total = 0; switch ($showTimeType) { case 0: //Show only timeslots added through the time panel $timeslots = Timeslots::getProjectTimeslots(logged_user()->getWorkspacesQuery(), $timeslotsUser, active_project(), $start, $limit); $total = Timeslots::countProjectTimeslots(logged_user()->getWorkspacesQuery(), $timeslotsUser, active_project()); break; case 1: //Show only timeslots added through the tasks panel / tasks throw new Error('not yet implemented' . $showTimeType); /*if (active_project() instanceof Project){ $workspacesCSV = active_project()->getAllSubWorkspacesQuery(false,logged_user()); } else { $workspacesCSV = logged_user()->getWorkspacesQuery(); } $taskTimeslots = Timeslots::getTaskTimeslots(null, $timeslotsUser, $workspacesCSV, null , null, null, null,0,20);*/ //break; /*if (active_project() instanceof Project){ $workspacesCSV = active_project()->getAllSubWorkspacesQuery(false,logged_user()); } else { $workspacesCSV = logged_user()->getWorkspacesQuery(); } $taskTimeslots = Timeslots::getTaskTimeslots(null, $timeslotsUser, $workspacesCSV, null , null, null, null,0,20);*/ //break; case 2: //Show timeslots added through both the time and tasks panel / tasks throw new Error('not yet implemented' . $showTimeType); //break; //break; default: throw new Error('Unrecognised TM show time type: ' . $showTimeType); } //Get Users Info if (logged_user()->isMemberOfOwnerCompany()) { $users = Users::getAll(); } else { $users = logged_user()->getCompany()->getUsers(); } //Get Companies Info if (logged_user()->isMemberOfOwnerCompany()) { $companies = Companies::getCompaniesWithUsers(); } else { $companies = array(logged_user()->getCompany()); } tpl_assign('timeslots', $timeslots); tpl_assign('tasks', $tasks); tpl_assign('users', $users); tpl_assign('start', $start); tpl_assign('limit', $limit); tpl_assign('total', $total); tpl_assign('companies', $companies); ajx_set_no_toolbar(true); }
function view() { $this->addHelper("textile"); $weblink = ProjectWebpages::findById(get_id()); if (!$weblink instanceof ProjectWebpage) { flash_error(lang('weblink dnx')); ajx_current("empty"); return; } if (!$weblink->canView(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $weblink->setIsRead(logged_user()->getId(), true); tpl_assign('object', $weblink); ajx_extra_data(array("title" => $weblink->getObjectName(), 'icon' => 'ico-weblink')); ajx_set_no_toolbar(true); ApplicationReadLogs::createLog($weblink, ApplicationReadLogs::ACTION_READ); }
function view(){ //check auth $this->addHelper('textile'); ajx_set_no_toolbar(true); $event = ProjectEvents::findById(get_id()); if (isset($event) && $event != null) { if(!$event->canView(logged_user())){ flash_error(lang('no access permissions')); $this->redirectTo('event'); return ; } //read object for this user $event->setIsRead(logged_user()->getId(), true); tpl_assign('event', $event); tpl_assign('cal_action', 'view'); tpl_assign('view', array_var($_GET, 'view', 'month')); ajx_extra_data(array("title" => $event->getObjectName(), 'icon'=>'ico-calendar')); ApplicationReadLogs::createLog($event, ApplicationReadLogs::ACTION_READ); } else { flash_error(lang('event dnx')); ajx_current("empty"); return ; } }
/** * View task page * * @access public * @param void * @return null */ function view() { $task_list = ProjectTasks::findById(get_id()); $this->addHelper('textile'); if (!$task_list instanceof ProjectTask) { flash_error(lang('task list dnx')); ajx_current("empty"); return; } // if if (!$task_list->canView(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if //read object for this user $task_list->setIsRead(logged_user()->getId(), true); tpl_assign('task_list', $task_list); $this->addHelper('textile'); ajx_extra_data(array("title" => $task_list->getObjectName(), 'icon' => 'ico-task')); ajx_set_no_toolbar(true); ApplicationReadLogs::createLog($task_list, ApplicationReadLogs::ACTION_READ); }
/** * @author Ignacio Vazquez */ function main_dashboard() { ajx_set_no_toolbar(true); }
function list_members() { if (!logged_user()->isAdminGroup()) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } ajx_set_no_toolbar(); $dim_id = array_var($_REQUEST, 'dim', 0); $dimension = Dimensions::findById($dim_id); if (!$dimension instanceof Dimension) { flash_error(lang('dimension snx')); ajx_current("empty"); return; } if (isset($_REQUEST['page'])) { ajx_replace(true); } // parameters $page = array_var($_REQUEST, 'page'); $order_by = array_var($_REQUEST, 'order'); $order_by_dir = array_var($_REQUEST, 'order_dir'); // pagination params $items_x_page = array_var($_REQUEST, 'items_x_page', 20); if (!$page) { $page = 1; } $offset = $items_x_page * ($page - 1); // order defaults if (!$order_by) { $order_by = 'name'; } if (!in_array($order_by_dir, array('ASC', 'DESC'))) { $order_by_dir = 'ASC'; } // this function already checks dimension options $dim_name = $dimension->getName(); // permissions sql $perm_sql = ""; if ($dimension->getDefinesPermissions() && !logged_user()->isAdministrator()) { $pg_ids = logged_user()->getPermissionGroupIds(); $perm_sql = " AND EXISTS (SELECT cmp.member_id FROM " . TABLE_PREFIX . "contact_member_permissions cmp WHERE cmp.member_id=m.id AND cmp.permission_group_id IN (" . implode(',', $pg_ids) . "))"; } $main_sql = "SELECT m.id, l.created_on, l.created_by_id, l.member_id FROM " . TABLE_PREFIX . "members m LEFT JOIN " . TABLE_PREFIX . "application_logs l ON l.member_id=m.id AND l.action='add' WHERE m.dimension_id='{$dim_id}' {$perm_sql}"; $sql = "{$main_sql}\r\n\t\t\t\tORDER BY {$order_by} {$order_by_dir} \r\n\t\t\t\tLIMIT {$offset}, {$items_x_page}"; $rows = DB::executeAll($sql); $count_sql = str_replace("SELECT m.id, l.created_on, l.created_by_id, l.member_id FROM", "SELECT count(*) as total FROM", $main_sql); $count_row = DB::executeAll($count_sql); $members = array(); $ids = array(); $log_data = array(); foreach ($rows as $row) { $members[] = Members::findById($row['id']); $log_data[$row['id']] = array('created_on' => $row['created_on'], 'created_by_id' => $row['created_by_id']); } $member_type_ids = array_flat(DB::executeAll("SELECT object_type_id FROM " . TABLE_PREFIX . "dimension_object_types WHERE dimension_id={$dim_id} AND is_root=1")); $member_types = ObjectTypes::findAll(array('conditions' => 'id IN (' . implode(',', $member_type_ids) . ')')); tpl_assign('members', $members); tpl_assign('log_data', $log_data); tpl_assign('dimension', $dimension); tpl_assign('dimension_name', $dim_name); tpl_assign('member_types', $member_types); tpl_assign('page', $page); tpl_assign('total_items', $count_row[0]['total']); tpl_assign('items_x_page', $items_x_page); tpl_assign('order_by', $order_by); tpl_assign('order_by_dir', $order_by_dir); }
/** * Show user card * * @access public * @param void * @return null */ function card() { $user = Users::findById(get_id()); if (!$user instanceof User) { flash_error(lang('user dnx')); ajx_current("empty"); return; } // if if (!logged_user()->canSeeUser($user)) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if $pids = null; if (active_project() instanceof Project) { $pids = active_project()->getAllSubWorkspacesQuery(); } if (logged_user()->isAdministrator() || logged_user()->getId() == get_id()) { $logs = ApplicationLogs::getOverallLogs(false, false, $pids, 15, 0, get_id()); tpl_assign('logs', $logs); tpl_assign('user_id', get_id()); } tpl_assign('user', $user); ajx_set_no_toolbar(true); ajx_extra_data(array("title" => $user->getDisplayName(), 'icon' => 'ico-user')); }