/** * 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 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); }
function view_custom_report() { $report_id = array_var($_GET, 'id'); tpl_assign('id', $report_id); if (isset($report_id)) { $report = Reports::getReport($report_id); $conditions = ReportConditions::getAllReportConditions($report_id); $paramConditions = array(); foreach ($conditions as $condition) { if ($condition->getIsParametrizable()) { $paramConditions[] = $condition; } } eval('$managerInstance = ' . $report->getObjectType() . "::instance();"); $externalCols = $managerInstance->getExternalColumns(); $externalFields = array(); foreach ($externalCols as $extCol) { $externalFields[$extCol] = $this->get_ext_values($extCol, $report->getObjectType()); } $params = array_var($_GET, 'params'); if (count($paramConditions) > 0 && !isset($params)) { $this->setTemplate('custom_report_parameters'); tpl_assign('model', $report->getObjectType()); tpl_assign('title', $report->getName()); tpl_assign('description', $report->getDescription()); tpl_assign('conditions', $paramConditions); tpl_assign('external_fields', $externalFields); } else { $this->setTemplate('report_wrapper'); tpl_assign('template_name', 'view_custom_report'); tpl_assign('title', $report->getName()); tpl_assign('genid', gen_id()); $parameters = ''; if (isset($params)) { foreach ($params as $id => $value) { $parameters .= '¶ms[' . $id . ']=' . $value; } } tpl_assign('parameterURL', $parameters); $offset = array_var($_GET, 'offset'); if (!isset($offset)) { $offset = 0; } $limit = array_var($_GET, 'limit'); if (!isset($limit)) { $limit = 50; } $order_by = array_var($_GET, 'order_by'); if (!isset($order_by)) { $order_by = ''; } tpl_assign('order_by', $order_by); $order_by_asc = array_var($_GET, 'order_by_asc'); if (!isset($order_by_asc)) { $order_by_asc = true; } tpl_assign('order_by_asc', $order_by_asc); $results = Reports::executeReport($report_id, $params, $order_by, $order_by_asc, $offset, $limit); if (!isset($results['columns'])) { $results['columns'] = array(); } tpl_assign('columns', $results['columns']); tpl_assign('db_columns', $results['db_columns']); if (!isset($results['rows'])) { $results['rows'] = array(); } tpl_assign('rows', $results['rows']); if (!isset($results['pagination'])) { $results['pagination'] = ''; } tpl_assign('pagination', $results['pagination']); tpl_assign('types', self::get_report_column_types($report_id)); tpl_assign('post', $params); tpl_assign('model', $report->getObjectType()); tpl_assign('description', $report->getDescription()); tpl_assign('conditions', $conditions); tpl_assign('parameters', $params); tpl_assign('id', $report_id); tpl_assign('to_print', false); } ApplicationReadLogs::createLog($report, "", ApplicationReadLogs::ACTION_READ); } }
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_history() { $id = array_var($_GET, 'id'); $obj = Objects::findObject($id); $isUser = $obj instanceof Contact && $obj->isUser() ? true : false; if (!$obj instanceof ApplicationDataObject) { flash_error(lang('object dnx')); ajx_current("empty"); return; } // if if ($isUser && (logged_user()->getId() != $id && !logged_user()->isAdministrator())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if if (!$isUser && !$obj->canView(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $logs = ApplicationLogs::getObjectLogs($obj); $logs_read = ApplicationReadLogs::getObjectLogs($obj); tpl_assign('object', $obj); tpl_assign('logs', $logs); tpl_assign('logs_read', $logs_read); }
/** * 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 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"); } }
/** * Download specific file * * @param void * @return null */ function download_file() { ajx_current("empty"); $inline = (bool) array_var($_GET, 'inline', false); $file = ProjectFiles::findById(get_id()); if (!$file instanceof ProjectFile) { flash_error(lang('file dnx')); return; } // if if (!$file->canDownload(logged_user())) { flash_error(lang('no access permissions')); return; } // if if ($file->getTypeString() == 'sprd') { die(lang("not implemented")); } session_commit(); if (array_var($_GET, 'checkout')) { if (get_id('checkout') == 1) { if (!$file->checkOut()) { flash_error(lang('document checked out')); return; } } } if (get_id('validate') == 1) { evt_add('download document', array('id' => get_id(), 'reloadDocs' => true)); return; } $file->setIsRead(logged_user()->getId(), true); ApplicationReadLogs::createLog($file, $file->getWorkspaces(), ApplicationReadLogs::ACTION_DOWNLOAD); download_from_repository($file->getLastRevision()->getRepositoryId(), $file->getTypeString(), $file->getFilename(), !$inline); die; }
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); }
/** * View task page * * @access public * @param void * @return null */ function view_task() { $task_list = ProjectTasks::findById(get_id()); $this->addHelper('textile'); $this->setTemplate('view_list'); 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); /*if(active_project()){ $open=active_project()->getOpenTasks(); $comp=active_project()->getCompletedTasks(); } else{ $projects=active_projects(); foreach ($projects as $p){ $open[] = $p->getOpenTasks(); $comp[] = $p->getCompletedTasks(); } }*/ $this->addHelper('textile'); ajx_extra_data(array("title" => $task_list->getTitle(), 'icon' => 'ico-task')); ajx_set_no_toolbar(true); ApplicationReadLogs::createLog($task_list, $task_list->getWorkspaces(), 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 ; } }
function view_history() { $id = array_var($_GET, 'id'); $manager = array_var($_GET, 'manager'); $obj = get_object_by_manager_and_id($id, $manager); if (!$obj instanceof ApplicationDataObject) { flash_error(lang('object dnx')); ajx_current("empty"); return; } // if if (!$obj->canView(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if if ($obj instanceof User && (logged_user()->getId() != $id && !logged_user()->isAdministrator())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if $logs = ApplicationLogs::getObjectLogs($obj); $logs_read = ApplicationReadLogs::getObjectLogs($obj); tpl_assign('object', $obj); tpl_assign('logs', $logs); tpl_assign('logs_read', $logs_read); }
/** * 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); }
function view_history() { $id = array_var($_GET, 'id'); $obj = Objects::findObject($id); $page_size = 20; $limit = $page_size; // get submitted modification logs page $mod_page_submitted = array_var($_REQUEST, 'mod_page'); $mod_page = $mod_page_submitted ? $mod_page_submitted : 1; $mod_offset = $page_size * ($mod_page - 1); // get submitted read logs page $view_page_submitted = array_var($_REQUEST, 'view_page'); $view_page = $view_page_submitted ? $view_page_submitted : 1; $view_offset = $page_size * ($view_page - 1); $isUser = $obj instanceof Contact && $obj->isUser() ? true : false; if (!$obj instanceof ApplicationDataObject) { flash_error(lang('object dnx')); ajx_current("empty"); return; } // if if ($isUser && (logged_user()->getId() != $id && !logged_user()->isAdministrator())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if if (!$isUser && !$obj->canView(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if logged user is guest don't show other users logs $extra_conditions = ""; if (logged_user()->isGuest()) { $extra_conditions = " AND `created_by_id` = " . logged_user()->getId(); } $logs = ApplicationLogs::getObjectLogs($obj, false, true, $limit, $mod_offset, $extra_conditions); $logs_read = ApplicationReadLogs::getObjectLogs($obj, $limit, $view_offset, $extra_conditions); // build modification logs pagination object $total_logs = ApplicationLogs::countObjectLogs($obj, false, true, $extra_conditions); $mod_logs_pagination = array('total_pages' => ceil($total_logs / $page_size), 'current_page' => $mod_page); // build read logs pagination object $total_read_logs = ApplicationReadLogs::countObjectLogs($obj, $extra_conditions); $view_logs_pagination = array('total_pages' => ceil($total_read_logs / $page_size), 'current_page' => $view_page); if ($mod_page_submitted || $view_page_submitted) { ajx_replace(true); } tpl_assign('object', $obj); tpl_assign('logs', $logs); tpl_assign('logs_read', $logs_read); tpl_assign('mod_logs_pagination', $mod_logs_pagination); tpl_assign('view_logs_pagination', $view_logs_pagination); tpl_assign('curtab', array_var($_REQUEST, 'curtab', '')); }
/** * 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); }
/** * 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); }
/** * 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, 'ApplicationReadLogs')) { return parent::paginate($arguments, $items_per_page, $current_page); } else { return ApplicationReadLogs::instance()->paginate($arguments, $items_per_page, $current_page); //$instance =& ApplicationReadLogs::instance(); //return $instance->paginate($arguments, $items_per_page, $current_page); } // if }
/** * View single contact * * @access public * @param void * @return null */ function card() { $contact = Contacts::findById(get_id()); if (!$contact || !$contact->canView(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if $roles = ProjectContacts::getRolesByContact($contact); if (isset($roles)) { foreach ($roles as $role) { $tags[$role->getProjectId()] = $role->getTagNames(); } } tpl_assign('contact', $contact); if (($uid = $contact->getUserId()) && ($usr = Users::findById($uid))) { tpl_assign('user', $usr); } if (isset($roles)) { tpl_assign('roles', $roles); } if (isset($tags)) { tpl_assign('tags', $tags); } ajx_extra_data(array("title" => $contact->getDisplayName(), 'icon' => 'ico-contact')); ajx_set_no_toolbar(true); ApplicationReadLogs::createLog($contact, $contact->getWorkspaces(), ApplicationReadLogs::ACTION_READ); }