function getMaxUID($folder = null) { $maxUID = 0; $sql = "SELECT `uid` FROM `" . MailContents::instance()->getTableName() . "` WHERE `account_id` = " . $this->getId(); if (!is_null($folder)) { $sql .= " AND `imap_folder_name` = '{$folder}'"; } $sql .= " AND id = (SELECT max(id) FROM `" . MailContents::instance()->getTableName() . "` WHERE `account_id` = " . $this->getId() . " AND `state` < 2)"; $rows = DB::executeAll($sql); if (isset($rows)) { $maxUID = $rows[0]['uid']; } return $maxUID; }
<?php $genid = gen_id(); ?> <form id='formClassify' name='formClassify' style='height:100%;background-color:white' class="internalForm" action="<?php echo get_url('mail','classify', array('id'=>$email->getId())) ?>" method="post"> <div class="classify"> <?php render_member_selectors(MailContents::instance()->getObjectTypeId(), $genid, $email->getMemberIds()); ?> </div> <input type="hidden" name="id" value="<?php echo $email->getId() ?>" /> <input type="hidden" name="submit" value="1" /> <?php echo submit_button(lang('classify'), 's', array('tabindex' => '50')) ?> </form>
echo yes_no_widget('mailAccount[mark_read_on_server]', 'mailAccountMarkReadOnServer', $mark_read_on_server > 0, lang('yes'), lang('no'), 130); ?> </div> <div class="mail-account-item dataBlock"> <label> <?php echo lang('classify mails on workspace'); ?> </label> <?php if ($mailAccount->isNew()) { render_member_selectors(MailContents::instance()->getObjectTypeId(), $genid, null, array('select_current_context' => true, 'hide_label' => true)); } else { render_member_selectors(MailContents::instance()->getObjectTypeId(), $genid, explode(',', $mailAccount->getMemberId())); } ?> <span class="desc"><?php echo lang('classify mails on workspace desc'); ?> </span> </div> <div class="clear"></div> </div> <div id="<?php echo $genid; ?>
/** * 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, $count = null) { if(isset($this) && instance_of($this, 'MailContents')) { return parent::paginate($arguments, $items_per_page, $current_page, $count); } else { return MailContents::instance()->paginate($arguments, $items_per_page, $current_page, $count); } // if } // paginate
/** * Check if specific user can add contacts to specific project * * @access public * @param User $user * @param Project $project * @return booelean */ function canAdd(User $user, Project $project) { return can_add($user, $project, get_class(MailContents::instance())); }
function getMaxUID($folder = null){ $maxUID = ""; $box_cond = ""; $sql = "SELECT `uid` FROM `" . MailContents::instance()->getTableName() . "` WHERE `account_id` = ". $this->getId(); if (!is_null($folder)) { $box_cond = " AND `imap_folder_name` = '$folder'"; } $sql .= "$box_cond AND object_id = (SELECT max(object_id) FROM `". MailContents::instance()->getTableName() . "` WHERE `account_id` = ". $this->getId(). " AND `state` < 2 $box_cond) LIMIT 1"; $res = DB::execute($sql); $rows = $res->fetchAll(); if (is_array($rows) && count($rows) > 0){ $maxUID = $rows[0]['uid']; } return $maxUID; }
<?php if (logged_user()->hasMailAccounts()) { $limit = 10; $result = MailContents::instance()->listing(array("order" => "sent_date", "order_dir" => "desc", "start" => 0, "limit" => $limit)); $active_members = array(); $context = active_context(); foreach ($context as $selection) { if ($selection instanceof Member) { $active_members[] = $selection; } } if (count($active_members) > 0) { $mnames = array(); $allowed_contact_ids = array(); foreach ($active_members as $member) { $mnames[] = clean($member->getName()); } $widget_title = lang('unread emails') . ' ' . lang('in') . ' ' . implode(", ", $mnames); } $total = $result->total; $emails = $result->objects; $genid = gen_id(); if ($total > 0) { include_once 'template.php'; } }
/** * Return manager instance * * @access protected * @param void * @return MailContents */ function manager() { if(!($this->manager instanceof MailContents)) $this->manager = MailContents::instance(); return $this->manager; } // manager
/** * Returns array of queries that will return Dashboard Objects * * @param string $proj_ids * @param string $tag * @param boolean $count if false the query will return objects, if true it will return object count */ static function getDashboardObjectQueries($project = null, $tag = null, $count = false, $trashed = false, $linkedObject = null, $order = 'updatedOn', $filterName = '', $archived = false, $filterManager = '') { if ($trashed && $trashed !== 'all') { $order = 'trashedOn'; } else { if ($archived) { $order = 'archivedOn'; } } switch ($order) { case 'dateCreated': $order_crit_companies = '`created_on`'; $order_crit_contacts = '`created_on`'; $order_crit_file_revisions = '`created_on`'; $order_crit_calendar = '`created_on`'; $order_crit_tasks = '`created_on`'; $order_crit_milestones = '`created_on`'; $order_crit_webpages = '`created_on`'; $order_crit_files = '`created_on`'; $order_crit_emails = '`received_date`'; $order_crit_comments = '`created_on`'; $order_crit_messages = '`created_on`'; $order_crit_workspaces = '`created_on`'; break; case 'trashedOn': $order_crit_companies = '`trashed_on`'; $order_crit_contacts = '`trashed_on`'; $order_crit_file_revisions = '`trashed_on`'; $order_crit_calendar = '`trashed_on`'; $order_crit_tasks = '`trashed_on`'; $order_crit_milestones = '`trashed_on`'; $order_crit_webpages = '`trashed_on`'; $order_crit_files = '`trashed_on`'; $order_crit_emails = '`trashed_on`'; $order_crit_comments = '`trashed_on`'; $order_crit_messages = '`trashed_on`'; $order_crit_workspaces = '`updated_on`'; break; case 'archivedOn': $order_crit_companies = '`archived_on`'; $order_crit_contacts = '`archived_on`'; $order_crit_file_revisions = '`updated_on`'; $order_crit_calendar = '`archived_on`'; $order_crit_tasks = '`archived_on`'; $order_crit_milestones = '`archived_on`'; $order_crit_webpages = '`archived_on`'; $order_crit_files = '`archived_on`'; $order_crit_emails = '`archived_on`'; $order_crit_comments = '`updated_on`'; $order_crit_messages = '`archived_on`'; $order_crit_workspaces = '`completed_on`'; break; case 'name': $order_crit_companies = '`name`'; $order_crit_contacts = "TRIM(CONCAT(' ', `lastname`, `firstname`, `middlename`))"; $order_crit_file_revisions = "'zzzzzzzzzzzzzz'"; //Revisar $order_crit_calendar = '`subject`'; $order_crit_tasks = '`title`'; $order_crit_milestones = '`name`'; $order_crit_webpages = '`title`'; $order_crit_files = '`filename`'; $order_crit_emails = '`subject`'; $order_crit_comments = '`text`'; $order_crit_messages = '`title`'; $order_crit_workspaces = '`name`'; break; default: $order_crit_companies = '`updated_on`'; $order_crit_contacts = '`updated_on`'; $order_crit_file_revisions = '`updated_on`'; $order_crit_calendar = '`updated_on`'; $order_crit_tasks = '`updated_on`'; $order_crit_milestones = '`updated_on`'; $order_crit_webpages = '`updated_on`'; $order_crit_files = '`updated_on`'; $order_crit_emails = '`received_date`'; $order_crit_comments = '`updated_on`'; $order_crit_messages = '`updated_on`'; $order_crit_workspaces = '`updated_on`'; break; } if ($project instanceof Project) { $proj_ids = $project->getAllSubWorkspacesQuery(true); $proj_cond_companies = Companies::getWorkspaceString($proj_ids); $proj_cond_messages = ProjectMessages::getWorkspaceString($proj_ids); $proj_cond_documents = ProjectFiles::getWorkspaceString($proj_ids); $proj_cond_emails = MailContents::getWorkspaceString($proj_ids); $proj_cond_events = ProjectEvents::getWorkspaceString($proj_ids); $proj_cond_tasks = ProjectTasks::getWorkspaceString($proj_ids); $proj_cond_charts = ProjectCharts::getWorkspaceString($proj_ids); $proj_cond_milestones = ProjectMilestones::getWorkspaceString($proj_ids); $proj_cond_weblinks = ProjectWebpages::getWorkspaceString($proj_ids); $proj_cond_contacts = Contacts::getWorkspaceString($proj_ids); } else { $proj_cond_companies = "true"; $proj_cond_messages = "true"; $proj_cond_documents = "true"; $proj_cond_emails = "true"; $proj_cond_events = "true"; $proj_cond_tasks = "true"; $proj_cond_charts = "true"; $proj_cond_milestones = "true"; $proj_cond_weblinks = "true"; $proj_cond_contacts = "true"; } if ($trashed) { if ($trashed === 'all') { $trashed_cond = '`trashed_on` >= ' . DB::escape(EMPTY_DATETIME); } else { $trashed_cond = '`trashed_on` > ' . DB::escape(EMPTY_DATETIME); } $archived_cond = '1 = 1'; // Show all objects in trash $comments_arch_cond = "1 = 1"; } else { $trashed_cond = '`trashed_on` = ' . DB::escape(EMPTY_DATETIME); if ($archived) { $archived_cond = "`archived_by_id` > 0"; $comments_arch_cond = "1 = 0"; // Don't show comments in archived objects listings } else { $archived_cond = "`archived_by_id` = 0"; $comments_arch_cond = "1 = 1"; } } if (isset($tag) && $tag && $tag != '') { $tag_str = " AND EXISTS (SELECT * FROM `" . TABLE_PREFIX . "tags` `t` WHERE `tag`= " . DB::escape($tag) . " AND `co`.`id` = `t`.`rel_object_id` AND `t`.`rel_object_manager` = `object_manager_value`) "; } else { $tag_str = ' '; } if ($linkedObject instanceof ProjectDataObject) { $link_id = $linkedObject->getId(); $link_mgr = get_class($linkedObject->manager()); $link_str = " AND EXISTS (SELECT * FROM `" . TABLE_PREFIX . "linked_objects` `t` WHERE\n\t\t\t(`t`.`object_id`=" . DB::escape($link_id) . " AND `t`.object_manager = " . DB::escape($link_mgr) . " AND `co`.`id` = `t`.`rel_object_id` AND `t`.`rel_object_manager` = `object_manager_value`) OR\n\t\t\t(`t`.`rel_object_id`=" . DB::escape($link_id) . " AND `t`.rel_object_manager = " . DB::escape($link_mgr) . " AND `co`.`id` = `t`.`object_id` AND `t`.`object_manager` = `object_manager_value`)) "; } else { $link_str = ' '; } $tag_str .= $link_str; $res = array(); /** If the name of the query ends with Comments it is assumed to be a list of Comments **/ $cfn = ''; if ($filterName != '') { $cfn = " AND text LIKE '%" . $filterName . "%'"; } // Notes if (module_enabled('notes')) { $fn = ''; if ($filterName != '') { $fn = " AND title LIKE '%" . $filterName . "%'"; } $permissions = ' AND ( ' . permissions_sql_for_listings(ProjectMessages::instance(), ACCESS_LEVEL_READ, logged_user(), '`project_id`', '`co`') . ')'; if ($filterManager == '' || $filterManager == "ProjectMessages") { $res['ProjectMessages'] = "SELECT 'ProjectMessages' AS `object_manager_value`, `id` AS `oid`, {$order_crit_messages} AS `order_value` FROM `" . TABLE_PREFIX . "project_messages` `co` WHERE " . $trashed_cond . " AND {$archived_cond} AND " . $proj_cond_messages . str_replace('= `object_manager_value`', "= 'ProjectMessages'", $tag_str) . $permissions . $fn; } if ($filterManager == '' || $filterManager == "Comments") { $res['ProjectMessagesComments'] = "SELECT 'Comments' AS `object_manager_value`, `id` AS `oid`, {$order_crit_comments} AS `order_value` FROM `" . TABLE_PREFIX . "comments` WHERE {$trashed_cond} AND `rel_object_manager` = 'ProjectMessages' AND `rel_object_id` IN (SELECT `co`.`id` FROM `" . TABLE_PREFIX . "project_messages` `co` WHERE `trashed_by_id` = 0 AND {$comments_arch_cond} AND " . $proj_cond_messages . str_replace('= `object_manager_value`', "= 'ProjectMessages'", $tag_str) . $permissions . $cfn . ")"; } } // Events if (module_enabled("calendar")) { $fn = ''; if ($filterName != '') { $fn = " AND subject LIKE '%" . $filterName . "%'"; } $permissions = ' AND ( ' . permissions_sql_for_listings(ProjectEvents::instance(), ACCESS_LEVEL_READ, logged_user(), '`project_id`', '`co`') . ')'; if ($filterManager == '' || $filterManager == "ProjectEvents") { $res['ProjectEvents'] = "SELECT 'ProjectEvents' AS `object_manager_value`, `id` AS `oid`, {$order_crit_calendar} AS `order_value` FROM `" . TABLE_PREFIX . "project_events` `co` WHERE " . $trashed_cond . " AND {$archived_cond} AND " . $proj_cond_events . str_replace('= `object_manager_value`', "= 'ProjectEvents'", $tag_str) . $permissions . $fn; } if ($filterManager == '' || $filterManager == "Comments") { $res['ProjectEventsComments'] = "SELECT 'Comments' AS `object_manager_value`, `id` AS `oid`, {$order_crit_comments} AS `order_value` FROM `" . TABLE_PREFIX . "comments` WHERE {$trashed_cond} AND `rel_object_manager` = 'ProjectEvents' AND `rel_object_id` IN (SELECT `co`.`id` FROM `" . TABLE_PREFIX . "project_events` `co` WHERE `trashed_by_id` = 0 AND {$comments_arch_cond} AND " . $proj_cond_events . str_replace('= `object_manager_value`', "= 'ProjectEvents'", $tag_str) . $permissions . $cfn . ")"; } } // Documents if (module_enabled("documents")) { $fn = ''; if ($filterName != '') { $fn = " AND filename LIKE '%" . $filterName . "%'"; } $permissions = ' AND ( ' . permissions_sql_for_listings(ProjectFiles::instance(), ACCESS_LEVEL_READ, logged_user(), '`project_id`', '`co`') . ')'; $typestring = array_var($_GET, "typestring"); if ($typestring) { $typecond = " AND ((SELECT count(*) FROM `" . TABLE_PREFIX . "project_file_revisions` `pfr` WHERE `" . "pfr`.`type_string` LIKE " . DB::escape($typestring) . " AND `" . "co`.`id` = `pfr`.`file_id`) > 0)"; } else { $typecond = ""; } if ($filterManager == '' || $filterManager == "ProjectFiles") { $res['ProjectFiles'] = "SELECT 'ProjectFiles' AS `object_manager_value`, `id` as `oid`, {$order_crit_files} AS `order_value` FROM `" . TABLE_PREFIX . "project_files` `co` WHERE " . $trashed_cond . " AND {$archived_cond} AND " . $proj_cond_documents . str_replace('= `object_manager_value`', "= 'ProjectFiles'", $tag_str) . $permissions . $typecond . $fn; } if ($filterManager == '' || $filterManager == "Comments") { $res['ProjectFilesComments'] = "SELECT 'Comments' AS `object_manager_value`, `id` AS `oid`, {$order_crit_comments} AS `order_value` FROM `" . TABLE_PREFIX . "comments` WHERE {$trashed_cond} AND `rel_object_manager` = 'ProjectFiles' AND `rel_object_id` IN (SELECT `co`.`id` FROM `" . TABLE_PREFIX . "project_files` `co` WHERE `trashed_by_id` = 0 AND {$comments_arch_cond} AND " . $proj_cond_documents . str_replace('= `object_manager_value`', "= 'ProjectFiles'", $tag_str) . $permissions . $cfn . ")"; } if ($trashed) { $file_rev_docs = "SELECT `id` FROM `" . TABLE_PREFIX . "project_files` `co` WHERE `trashed_by_id` = 0 AND " . $proj_cond_documents . str_replace('= `object_manager_value`', "= 'ProjectFiles'", $tag_str) . $permissions . $typecond; $res['FileRevisions'] = "SELECT 'ProjectFileRevisions' AS `object_manager_value`, `id` AS `oid`, {$order_crit_file_revisions} AS `order_value` FROM `" . TABLE_PREFIX . "project_file_revisions` `co` WHERE {$trashed_cond} AND `file_id` IN (" . $file_rev_docs . ")"; } } // Tasks and Milestones if (module_enabled("tasks")) { $fn = ''; if ($filterName != '') { $fn = " AND title LIKE '%" . $filterName . "%'"; } $completed = $trashed || $archived ? '' : 'AND `completed_on` = ' . DB::escape(EMPTY_DATETIME); $permissions = ' AND ( ' . permissions_sql_for_listings(ProjectTasks::instance(), ACCESS_LEVEL_READ, logged_user(), '`project_id`', '`co`') . ')'; if ($filterManager == '' || $filterManager == "ProjectTasks") { $res['ProjectTasks'] = "SELECT 'ProjectTasks' AS `object_manager_value`, `id` AS `oid`, {$order_crit_tasks} AS `order_value` FROM `" . TABLE_PREFIX . "project_tasks` `co` WHERE `is_template` = false {$completed} AND " . $trashed_cond . " AND {$archived_cond} AND `is_template` = false AND " . $proj_cond_tasks . str_replace('= `object_manager_value`', "= 'ProjectTasks'", $tag_str) . $permissions . $fn; } if ($filterManager == '' || $filterManager == "Comments") { $res['ProjectTasksComments'] = "SELECT 'Comments' AS `object_manager_value`, `id` AS `oid`, {$order_crit_comments} AS `order_value` FROM `" . TABLE_PREFIX . "comments` WHERE {$trashed_cond} AND `rel_object_manager` = 'ProjectTasks' AND `rel_object_id` IN (SELECT `co`.`id` FROM `" . TABLE_PREFIX . "project_tasks` `co` WHERE `trashed_by_id` = 0 AND {$comments_arch_cond} AND `is_template` = false AND " . $proj_cond_tasks . str_replace('= `object_manager_value`', "= 'ProjectTasks'", $tag_str) . $permissions . $cfn . ")"; } $fn = ''; if ($filterName != '') { $fn = " AND name LIKE '%" . $filterName . "%'"; } $permissions = ' AND ( ' . permissions_sql_for_listings(ProjectMilestones::instance(), ACCESS_LEVEL_READ, logged_user(), '`project_id`', '`co`') . ')'; if ($filterManager == '' || $filterManager == "ProjectMilestones") { $res['ProjectMilestones'] = "SELECT 'ProjectMilestones' AS `object_manager_value`, `id` AS `oid`, {$order_crit_milestones} AS `order_value` FROM `" . TABLE_PREFIX . "project_milestones` `co` WHERE " . $trashed_cond . " AND {$archived_cond} AND `is_template` = false AND " . $proj_cond_milestones . str_replace('= `object_manager_value`', "= 'ProjectMilestones'", $tag_str) . $permissions . $fn; } if ($filterManager == '' || $filterManager == "Comments") { $res['ProjectMilestonesComments'] = "SELECT 'Comments' AS `object_manager_value`, `id` AS `oid`, {$order_crit_comments} AS `order_value` FROM `" . TABLE_PREFIX . "comments` WHERE {$trashed_cond} AND `rel_object_manager` = 'ProjectMilestones' AND `rel_object_id` IN (SELECT `co`.`id` FROM `" . TABLE_PREFIX . "project_milestones` `co` WHERE `trashed_by_id` = 0 AND {$comments_arch_cond} AND `is_template` = false AND " . $proj_cond_milestones . str_replace('= `object_manager_value`', "= 'ProjectMilestones'", $tag_str) . $permissions . $cfn . ")"; } } // Weblinks if (module_enabled("weblinks")) { $fn = ''; if ($filterName != '') { $fn = " AND title LIKE '%" . $filterName . "%'"; } $permissions = ' AND ( ' . permissions_sql_for_listings(ProjectWebpages::instance(), ACCESS_LEVEL_READ, logged_user(), '`project_id`', '`co`') . ')'; if ($filterManager == '' || $filterManager == "ProjectWebpages") { $res['ProjectWebPages'] = "SELECT 'ProjectWebPages' AS `object_manager_value`, `id` AS `oid`, {$order_crit_webpages} AS `order_value` FROM `" . TABLE_PREFIX . "project_webpages` `co` WHERE " . $trashed_cond . " AND {$archived_cond} AND " . $proj_cond_weblinks . str_replace('= `object_manager_value`', "= 'ProjectWebpages'", $tag_str) . $permissions . $fn; } if ($filterManager == '' || $filterManager == "Comments") { $res['ProjectWebPagesComments'] = "SELECT 'Comments' AS `object_manager_value`, `id` AS `oid`, {$order_crit_comments} AS `order_value` FROM `" . TABLE_PREFIX . "comments` WHERE {$trashed_cond} AND `rel_object_manager` = 'ProjectWebpages' AND `rel_object_id` IN (SELECT `co`.`id` FROM `" . TABLE_PREFIX . "project_webpages` `co` WHERE " . $trashed_cond . " AND {$comments_arch_cond} AND " . $proj_cond_weblinks . str_replace('= `object_manager_value`', "= 'ProjectWebpages'", $tag_str) . $permissions . $cfn . ")"; } } // Email if (module_enabled("email")) { $fn = ''; if ($filterName != '') { $fn = " AND subject LIKE '%" . $filterName . "%'"; } $permissions = ' AND ( ' . permissions_sql_for_listings(MailContents::instance(), ACCESS_LEVEL_READ, logged_user(), $project instanceof Project ? $project->getId() : 0, '`co`') . ')'; if ($filterManager == '' || $filterManager == "MailContents") { $res['MailContents'] = "SELECT 'MailContents' AS `object_manager_value`, `id` AS `oid`, {$order_crit_emails} AS `order_value` FROM `" . TABLE_PREFIX . "mail_contents` `co` WHERE (" . $trashed_cond . " AND {$archived_cond} AND `is_deleted` = 0 AND " . $proj_cond_emails . str_replace('= `object_manager_value`', "= 'MailContents'", $tag_str) . $permissions . ") {$fn}"; } if ($filterManager == '' || $filterManager == "Comments") { $res['MailContentsComments'] = "SELECT 'Comments' AS `object_manager_value`, `id` AS `oid`, {$order_crit_comments} AS `order_value` FROM `" . TABLE_PREFIX . "comments` WHERE {$trashed_cond} AND `rel_object_manager` = 'MailContents' AND `rel_object_id` IN (SELECT `co`.`id` FROM `" . TABLE_PREFIX . "mail_contents` `co` WHERE `trashed_by_id` = 0 AND {$comments_arch_cond} AND " . $proj_cond_emails . str_replace('= `object_manager_value`', "= 'MailContents'", $tag_str) . $permissions . $cfn . ")"; } } // Conacts and Companies if (module_enabled("contacts")) { $fn = ''; $fn2 = ''; if ($filterName != '') { $fn = " AND firstname LIKE '%" . $filterName . "%'"; $fn2 = " AND name LIKE '%" . $filterName . "%'"; } // companies $permissions = ' AND ( ' . permissions_sql_for_listings(Companies::instance(), ACCESS_LEVEL_READ, logged_user(), '`project_id`', '`co`') . ')'; if ($filterManager == '' || $filterManager == "Companies") { $res['Companies'] = "SELECT 'Companies' AS `object_manager_value`, `id` as `oid`, {$order_crit_companies} AS `order_value` FROM `" . TABLE_PREFIX . "companies` `co` WHERE " . $trashed_cond . " AND {$archived_cond} AND " . $proj_cond_companies . str_replace('= `object_manager_value`', "= 'Companies'", $tag_str) . $permissions . $fn2; } $res['CompaniesComments'] = "SELECT 'Comments' AS `object_manager_value`, `id` AS `oid`, {$order_crit_comments} AS `order_value` FROM `" . TABLE_PREFIX . "comments` WHERE {$trashed_cond} AND `rel_object_manager` = 'Companies' AND `rel_object_id` IN (SELECT `co`.`id` FROM `" . TABLE_PREFIX . "companies` `co` WHERE `trashed_by_id` = 0 AND {$comments_arch_cond} AND " . $proj_cond_documents . str_replace('= `object_manager_value`', "= 'Companies'", $tag_str) . $permissions . $cfn . ")"; // contacts $permissions = ' AND ( ' . permissions_sql_for_listings(Contacts::instance(), ACCESS_LEVEL_READ, logged_user(), '`project_id`', '`co`') . ')'; if ($filterManager == '' || $filterManager == "Contacts") { $res['Contacts'] = "SELECT 'Contacts' AS `object_manager_value`, `id` AS `oid`, {$order_crit_contacts} AS `order_value` FROM `" . TABLE_PREFIX . "contacts` `co` WHERE {$trashed_cond} AND {$archived_cond} AND {$proj_cond_contacts} " . str_replace('= `object_manager_value`', "= 'Contacts'", $tag_str) . $permissions . $fn; } $res['ContactsComments'] = "SELECT 'Comments' AS `object_manager_value`, `id` AS `oid`, {$order_crit_comments} AS `order_value` FROM `" . TABLE_PREFIX . "comments` WHERE {$trashed_cond} AND `rel_object_manager` = 'Contacts' AND `rel_object_id` IN (SELECT `co`.`id` FROM `" . TABLE_PREFIX . "contacts` `co` WHERE `trashed_by_id` = 0 AND {$comments_arch_cond} AND " . $proj_cond_documents . str_replace('= `object_manager_value`', "= 'Contacts'", $tag_str) . $permissions . $cfn . ")"; } // Workspaces (only for archived objects view) if ($archived) { if ($filterManager == '' || $filterManager == "Projects") { $res['Projects'] = "SELECT 'Projects' AS `object_manager_value`, `id` AS `oid`, {$order_crit_workspaces} AS `order_value` FROM `" . TABLE_PREFIX . "projects` `co` WHERE `completed_on` <> " . DB::escape(EMPTY_DATETIME) . " AND `id` IN (" . logged_user()->getWorkspacesQuery() . ")"; } } if ($count) { foreach ($res as $p => $q) { $res[$p] = "SELECT count(*) AS `quantity`, '{$p}' AS `objectName` FROM ( {$q} ) `table_alias`"; } } return $res; }
<label> <?php echo lang('classify mails on workspace'); ?> <span class="desc"><?php echo lang('classify mails on workspace desc'); ?> </span> </label> <?php //alert_r($mailAccount); // TODO context PEPE if ($mailAccount->isNew()) { render_dimension_trees(MailContents::instance()->getObjectTypeId(), $genid, null, array('select_current_context' => true)); } else { render_dimension_trees(MailContents::instance()->getObjectTypeId(), $genid, $mailAccount->getMemberIds()); } ?> </div> </fieldset> <fieldset id="<?php echo $genid; ?> smtp_settings_div"> <legend><?php echo lang('smtp settings'); ?> </legend> <div class="mail-account-item">
/** * Prepares return object for a list of emails and messages * * @param array $totMsg * @param integer $start * @param integer $limit * @return array */ private function prepareObject($emails, $start, $limit, $total, $attributes = null) { $object = array("totalCount" => intval($total), "start" => $start, "messages" => array()); $custom_properties = CustomProperties::getAllCustomPropertiesByObjectType(MailContents::instance()->getObjectTypeId()); $i = 0; foreach ($emails as $email) { if ($email instanceof MailContent) { $properties = $this->getMailProperties($email, $i); $object["messages"][$i] = $properties; } foreach ($custom_properties as $cp) { $object["messages"][$i]['cp_' . $cp->getId()] = get_custom_property_value_for_listing($cp, $email); } $i++; } //set columns to show for this folder if (isset($attributes)) { $string = user_config_option("folder_" . $attributes["stateType"] . "_columns"); $columns = explode(",", $string); foreach ($columns as $col) { $object["folder_columns"][] = $col; } $object["folder_name"] = $attributes["stateType"]; //if you want to add a column add their name here too $object["folder_columns_all"] = array("from", "to", "subject", "account", "date", "folder", "actions"); } return $object; }
/** * Prepares return object for a list of emails and messages * * @param array $totMsg * @param integer $start * @param integer $limit * @return array */ private function prepareObject($emails, $start, $limit, $total, $attributes = null) { $object = array( "totalCount" => intval($total), "start" => $start,//(integer)min(array(count($totMsg) - (count($totMsg) % $limit),$start)), "messages" => array() ); $custom_properties = CustomProperties::getAllCustomPropertiesByObjectType(MailContents::instance()->getObjectTypeId()); $i=0; foreach ($emails as $email) { if ($email instanceof MailContent) { $properties = $this->getMailProperties($email, $i); $object["messages"][$i] = $properties; } foreach ($custom_properties as $cp) { $cp_value = CustomPropertyValues::getCustomPropertyValue($email->getId(), $cp->getId()); $object["messages"][$i]['cp_'.$cp->getId()] = $cp_value instanceof CustomPropertyValue ? $cp_value->getValue() : ''; } $i++; } return $object; }
/** * Return manager instance * * @access protected * @param void * @return MailContents */ function manager() { if (!$this->manager instanceof MailContents) { $this->manager = MailContents::instance(); } return $this->manager; }
static function prepareTrashAndArchivedConditions($trashed, $archived) { $trashed_cond = "`o`.`trashed_on` " . ($trashed ? ">" : "=") . " " . DB::escape(EMPTY_DATETIME); if ($trashed) { $archived_cond = ""; } else { $archived_cond = "AND `o`.`archived_on` " . ($archived ? ">" : "=") . " " . DB::escape(EMPTY_DATETIME); } if ($trashed && Plugins::instance()->isActivePlugin('mail')) { $mail_accounts = MailAccounts::getMailAccountsByUser(logged_user()); $mail_account_ids = array(); foreach ($mail_accounts as $account) { $mail_account_ids[] = $account->getId(); } $mcot_id = MailContents::instance()->getObjectTypeId(); if (empty($mail_account_ids)) { $trashed_cond .= " AND IF(o.object_type_id={$mcot_id}, 0, 1)"; } else { $trashed_cond .= " AND IF(o.object_type_id={$mcot_id}, NOT (SELECT mcx.is_deleted FROM " . TABLE_PREFIX . "mail_contents mcx WHERE mcx.object_id=o.id) AND EXISTS (SELECT mct.object_id FROM " . TABLE_PREFIX . "mail_contents mct WHERE mct.object_id=o.id AND mct.account_id IN(" . implode(',', $mail_account_ids) . ")), 1)"; } } return array($trashed_cond, $archived_cond); }
static function prepareTrashAndArchivedConditions($trashed, $archived){ $trashed_cond = "`o`.`trashed_on` " .($trashed ? ">" : "="). " " . DB::escape(EMPTY_DATETIME); if ($trashed) { $archived_cond = ""; } else { $archived_cond = "AND `o`.`archived_on` " .($archived ? ">" : "="). " " . DB::escape(EMPTY_DATETIME); } if ($trashed && Plugins::instance()->isActivePlugin('mail')) { $mcot_id = MailContents::instance()->getObjectTypeId(); $trashed_cond .= " AND IF(o.object_type_id=$mcot_id, NOT (SELECT mcx.is_deleted FROM ".TABLE_PREFIX."mail_contents mcx WHERE mcx.object_id=o.id), 1)"; } return array($trashed_cond, $archived_cond); }
function countUserInboxUnreadEmails() { $tp = TABLE_PREFIX; $uid = logged_user()->getId(); $sql = "SELECT count(*) `c` FROM `{$tp}mail_contents` `a`, `{$tp}read_objects` `b` WHERE `b`.`rel_object_manager` = 'MailContents' AND `b`.`rel_object_id` = `a`.`id` AND `b`.`user_id` = '{$uid}' AND `b`.`is_read` = '1' AND `a`.`trashed_on` = '0000-00-00 00:00:00' AND `a`.`is_deleted` = 0 AND `a`.`archived_by_id` = 0 AND (`a`.`state` = '0' OR `a`.`state` = '5') AND " . permissions_sql_for_listings(MailContents::instance(), ACCESS_LEVEL_READ, logged_user(), null, '`a`'); $rows = DB::executeAll($sql); $read = $rows[0]['c']; $sql = "SELECT count(*) `c` FROM `{$tp}mail_contents` `a` WHERE `a`.`trashed_on` = '0000-00-00 00:00:00' AND `a`.`is_deleted` = 0 AND `a`.`archived_by_id` = 0 AND (`a`.`state` = '0' OR `a`.`state` = '5') AND " . permissions_sql_for_listings(MailContents::instance(), ACCESS_LEVEL_READ, logged_user(), null, '`a`'); $rows = DB::executeAll($sql); $all = $rows[0]['c']; return $all - $read; }
function getMaxUID($folder = null) { $maxUID = ""; $box_cond = ""; $sql = "SELECT `uid` FROM `" . MailContents::instance()->getTableName() . "` WHERE `account_id` = " . $this->getId(); if (!is_null($folder)) { $box_cond = " AND `imap_folder_name` = '{$folder}'"; } if ($this->getIsImap()) { $max_param = "object_id"; } else { $max_param = "received_date"; } $sql .= "{$box_cond} AND {$max_param} = (SELECT max({$max_param}) FROM `" . MailContents::instance()->getTableName() . "` WHERE `account_id` = " . $this->getId() . " AND `state` in (0,1,4) {$box_cond}) LIMIT 1"; $res = DB::execute($sql); $rows = $res->fetchAll(); if (is_array($rows) && count($rows) > 0) { $maxUID = $rows[0]['uid']; } return $maxUID; }