private function loadPanels($options) { if (!$this->panels) { $contact_pg_ids = ContactPermissionGroups::getPermissionGroupIdsByContactCSV(logged_user()->getId(), false); $this->panels = array(); $sql = "\r\n\t\t\t\tSELECT * FROM " . TABLE_PREFIX . "tab_panels \r\n\t\t\t\tWHERE \r\n\t\t\t\t\tenabled = 1 AND\t\t\t\t\t\r\n\t\t\t\t\t( \t\r\n\t\t\t\t\t\tplugin_id IS NULL OR plugin_id=0 OR\r\n\t\t\t\t\t\tplugin_id IN (SELECT id FROM " . TABLE_PREFIX . "plugins WHERE is_installed = 1 AND is_activated = 1) \r\n\t\t\t\t\t)\r\n\t\t\t\t\tAND id IN (SELECT tab_panel_id FROM " . TABLE_PREFIX . "tab_panel_permissions WHERE permission_group_id IN ({$contact_pg_ids}))\r\n\t\t\t\tORDER BY ordering ASC "; $res = DB::execute($sql); while ($row = $res->fetchRow()) { $object = array("title" => lang($row['title']), "id" => $row['id'], "quickAddTitle" => lang($row['default_controller']), "refreshOnWorkspaceChange" => (bool) $row['refresh_on_context_change'], "defaultController" => $row['default_controller'], "defaultContent" => array("type" => "url", "data" => get_url($row['default_controller'], $row['default_action'])), "enabled" => $row['enabled'], "type" => $row['type'], "tabTip" => lang($row['title'])); if (config_option('show_tab_icons')) { $object["iconCls"] = $row['icon_cls']; } if ($row['initial_controller'] && $row['initial_action']) { $object["initialContent"] = array("type" => "url", "data" => get_url($row['initial_controller'], $row['initial_action'])); } if ($row['id'] == 'more-panel' && config_option('getting_started_step') >= 99) { $object['closable'] = true; if (!user_config_option('settings_closed')) { $this->panels[] = $object; } } else { $this->panels[] = $object; } } } return $this->panels; }
function mail_do_mark_as_read_unread_objects($ids_to_mark, $read) { $all_accounts = array(); $all_accounts_ids = array(); foreach ($ids_to_mark as $id) { $obj = Objects::findObject($id); if ($obj instanceof MailContent && logged_user() instanceof Contact) { //conversation set the rest of the conversation $uds_to_mark_from_conver = array(); if (user_config_option('show_emails_as_conversations')) { $emails_in_conversation = MailContents::getMailsFromConversation($obj); foreach ($emails_in_conversation as $email) { //$id is marked on object controller only mark the rest of the conversation if ($id != $email->getId()) { $email->setIsRead(logged_user()->getId(), $read); $uds_to_mark_from_conver[] = $email->getUid(); } } } //make the array with accounts and uids to send to the mail server //accounts if (!in_array($obj->getAccountId(), $all_accounts_ids)) { $account = $obj->getAccount(); //if logged user is owner of this account and is imap if ($account instanceof MailAccount && $account->getContactId() == logged_user()->getId() && $account->getIsImap()) { $all_accounts_ids[] = $obj->getAccountId(); $all_accounts[$account->getId()]['account'] = $account; } } //uids if (in_array($obj->getAccountId(), $all_accounts_ids)) { //add conversations uids //mientras ande mal el uid de los mails enviados si estan sincronizados no usar esta parte /*if (user_config_option('show_emails_as_conversations')) { foreach ($uds_to_mark_from_conver as $uid_conver){ $all_accounts[$obj->getAccountId()]['uids'][] = $uid_conver; } }*/ $all_accounts[$obj->getAccountId()]['folders'][$obj->getImapFolderName()][] = $obj->getUid(); } } } //foreach account send uids by folder to mark in the mail server foreach ($all_accounts as $account_data) { $account = $account_data['account']; $folders = $account_data['folders']; foreach ($folders as $key => $folder) { $folder_name = $key; $uids = $folder; if (!empty($folder_name)) { try { MailUtilities::setReadUnreadImapMails($account, $folder_name, $uids, $read); } catch (Exception $e) { Logger::log("Could not set mail as read on mail server, exception:\n" . $e->getMessage()); } } } } }
/** * 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); }
function getEventLimits($event, $date, &$event_start, &$event_duration, &$end_modified) { $end_modified = false; if ($event instanceof ProjectEvent) { $event_start = new DateTimeValue($event->getStart()->getTimestamp() + 3600 * logged_user()->getTimezone()); $event_duration = new DateTimeValue($event->getDuration()->getTimestamp() + 3600 * logged_user()->getTimezone()); } else { if ($event instanceof ProjectTask) { /* @var $event ProjectTask */ $work_day_start = new DateTimeValue($date->getTimestamp()); $wsd = user_config_option('work_day_start_time'); $work_day_start->setHour(substr($wsd, 0, strpos($wsd, ':'))); $work_day_start->setMinute(substr($wsd, strpos($wsd, ':') + 1)); if ($event->getStartDate() instanceof DateTimeValue) { $event_start = new DateTimeValue($event->getStartDate()->getTimestamp() + 3600 * logged_user()->getTimezone()); } else { if ($event->getTimeEstimate() > 0 && $event->getDueDate() instanceof DateTimeValue) { $event_start = new DateTimeValue($event->getDueDate()->getTimestamp() + 3600 * logged_user()->getTimezone()); $event_start->advance($event->getTimeEstimate() * -60); } else { $event_start = $work_day_start; } } $work_day_end = new DateTimeValue($date->getTimestamp()); $wed = user_config_option('work_day_end_time'); $work_day_end->setHour(substr($wed, 0, strpos($wed, ':'))); $work_day_end->setMinute(substr($wed, strpos($wed, ':') + 1)); if ($event->getDueDate() instanceof DateTimeValue) { $event_duration = new DateTimeValue($event->getDueDate()->getTimestamp() + 3600 * logged_user()->getTimezone()); } else { if ($event->getTimeEstimate() > 0 && $event->getStartDate() instanceof DateTimeValue) { $event_duration = new DateTimeValue($event_start->getTimestamp()); $event_duration->advance($event->getTimeEstimate() * 60); } else { $event_duration = $work_day_end; } } } } $tomorrow = new DateTimeValue($date->getTimestamp()); $tomorrow->add('d', 1); if ($event_duration->getTimestamp() > $tomorrow->getTimestamp()) { $event_duration = new DateTimeValue($tomorrow->getTimestamp()); $end_modified = true; } if ($event_start->getTimestamp() < $date->getTimestamp()) { if (!$event->isRepetitive()) { $event_start = new DateTimeValue($date->getTimestamp()); } else { $event_start->setDay($date->getDay()); $event_start->setMonth($date->getMonth()); $event_start->setYear($date->getYear()); } } }
function help_options() { $show_context_help = user_config_option('show_context_help', 'until_close', logged_user()->getId()); $show = true; if ($show_context_help == 'never') { $show = false; } tpl_assign('show_help', $show); ajx_set_panel('help'); ajx_replace(true); }
/** * Gets all the dimensions that user can see plus those wich must be displayed in the panels * */ function get_context(){ ajx_current("empty"); // User config root dimensions $dids = explode ("," ,user_config_option('root_dimensions', null, logged_user()->getId() )); foreach ($dids as $id) { if (is_numeric($id) && $id > 0 ) { $user_root_dimensions[$id] = true ; } } //All dimensions $all_dimensions = Dimensions::findAll(array('order'=>'default_order ASC , id ASC')); $dimensions_to_show = array(); $contact_pg_ids = ContactPermissionGroups::getPermissionGroupIdsByContactCSV(logged_user()->getId(),false); foreach ($all_dimensions as $dim){ $did = $dim->getId(); if (isset($user_root_dimensions) && count($user_root_dimensions)) { if ( isset($user_root_dimensions[$did]) && $user_root_dimensions[$did] ){ $dim->setIsRoot(true); }else{ $dim->setIsRoot(false); } } $added=false; if (!$dim->getDefinesPermissions()){ $dimensions_to_show ['dimensions'][] = $dim; $added = true; } else{ /*if dimension does not deny everything for each contact's PG, show it*/ if (!$dim->deniesAllForContact($contact_pg_ids)){ $dimensions_to_show ['dimensions'][] = $dim; $added = true; } } if ($dim->getIsRoot()&& $added){ $dimensions_to_show ['is_root'][] = true; } } return $dimensions_to_show; }
/** * Returns a list of emails according to the requested parameters * * @param string $tag * @param array $attributes * @param Project $project * @return array */ function getEmails($account_id = null, $state = null, $read_filter = "", $classif_filter = "", $context = null, $start = null, $limit = null, $order_by = 'received_date', $dir = 'ASC', $join_params = null, $archived = false, $conversation_list = null, $only_count_result = false) { $mailTablePrefix = "e"; if (!$limit) { $limit = user_config_option('mails_per_page') ? user_config_option('mails_per_page') : config_option('files_per_page'); } $accountConditions = ""; // Check for accounts $accountConditions = ''; if (isset($account_id) && $account_id > 0) { //Single account $accountConditions = " AND {$mailTablePrefix}.account_id = " . DB::escape($account_id); } else { // show mails for all visible accounts and classified mails where logged_user has permissions so we don't filter by account_id /*// show emails from other accounts $macs = MailAccountContacts::instance()->getByContact(logged_user()); $acc_ids = array(0); foreach ($macs as $mac) $acc_ids[] = $mac->getAccountId(); // permission conditions $pgs = ContactPermissionGroups::getPermissionGroupIdsByContactCSV(logged_user()->getId()); if (trim($pgs == '')) $pgs = '0'; $perm_sql = "(SELECT count(*) FROM ".TABLE_PREFIX."sharing_table st WHERE st.object_id = $mailTablePrefix.object_id AND st.group_id IN ($pgs)) > 0"; // show mails for all visible accounts and classified mails where logged_user has permissions $accountConditions = " AND ($mailTablePrefix.account_id IN (" . implode(",", $acc_ids) . ") OR $perm_sql)";*/ } // Check for unclassified emails $classified = ''; if ($classif_filter != '' && $classif_filter != 'all') { $persons_dim = Dimensions::findByCode('feng_persons'); $persons_dim_id = $persons_dim instanceof Dimension ? $persons_dim->getId() : "0"; $classified = "AND " . ($classif_filter == 'unclassified' ? "NOT " : ""); $classified .= "o.id IN (SELECT om.object_id FROM " . TABLE_PREFIX . "object_members om INNER JOIN " . TABLE_PREFIX . "members m ON m.id=om.member_id WHERE m.dimension_id<>{$persons_dim_id})"; } // if not filtering by account or classification then check that emails are classified or from one of my accounts if ($classified == '' && $accountConditions == '') { $macs = MailAccountContacts::instance()->getByContact(logged_user()); $acc_ids = array(0); foreach ($macs as $mac) { $acc_ids[] = $mac->getAccountId(); } $accountConditions = " AND ({$mailTablePrefix}.account_id IN (" . implode(',', $acc_ids) . ") OR EXISTS (\r\n\t\t\t\t\tSELECT om1.object_id FROM " . TABLE_PREFIX . "object_members om1 \r\n\t\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "members m1 ON m1.id=om1.member_id \r\n\t\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "dimensions d1 ON d1.id=m1.dimension_id \r\n\t\t\t\t\tWHERE om1.object_id={$mailTablePrefix}.object_id AND d1.is_manageable=1) ) "; } // Check for draft, junk, etc. emails if ($state == "draft") { $stateConditions = " {$mailTablePrefix}.state = '2'"; } else { if ($state == "sent") { $stateConditions = " {$mailTablePrefix}.state IN ('1','3','5')"; } else { if ($state == "received") { $stateConditions = " {$mailTablePrefix}.state IN ('0','5')"; } else { if ($state == "junk") { $stateConditions = " {$mailTablePrefix}.state = '4'"; } else { if ($state == "outbox") { $stateConditions = " {$mailTablePrefix}.state >= 200"; } else { $stateConditions = ""; } } } } } // Check read emails if ($read_filter != "" && $read_filter != "all") { if ($read_filter == "unread") { $read = "AND NOT "; $subread = "AND NOT mc."; } else { $read = "AND "; $subread = "AND mc."; } $read2 = "id IN (SELECT rel_object_id FROM " . TABLE_PREFIX . "read_objects t WHERE contact_id = " . logged_user()->getId() . " AND id = t.rel_object_id AND t.is_read = '1')"; $read .= $read2; $subread .= $read2; } else { $read = ""; $subread = ""; } $conversation_cond = ""; $box_cond = "AND {$stateConditions}"; if (isset($conversation_list) && $conversation_list > 0) { $conversation_cond = "AND e.conversation_last = 1"; } $extra_conditions = "{$accountConditions} {$classified} {$read} {$conversation_cond} {$box_cond}"; Hook::fire("listing_extra_conditions", null, $extra_conditions); return self::instance()->listing(array('limit' => $limit, 'start' => $start, 'order' => $order_by, 'order_dir' => $dir, 'extra_conditions' => $extra_conditions, 'count_results' => false, 'only_count_results' => $only_count_result, 'join_params' => $join_params)); }
fclose($handle); } // CONTENT NO QUOTED NO IMAGES $html_no_quoted_no_images = MailUtilities::replaceQuotedBlocks($html_no_images, '<div style="color: #777;font-style:italic;padding: 5px 20px"><'.lang('hidden quoted text').'></div>'); $tmppath = ROOT.'/tmp/iq_'.$tmpfile; $handle = fopen($tmppath, 'wb'); if ($handle) { fwrite($handle, $html_no_quoted_no_images); fclose($handle); } // VIEW CONTENT (iframe and links) $remove_images = false; $remove_quoted = false; if (user_config_option('block_email_images') && html_has_images($html_content)) { $remove_images = true; } if ($hide_quoted_text_in_emails && MailUtilities::hasQuotedBlocks($html_content)) { $remove_quoted = true; } $pre = $email->getAccountId() . '_' . logged_user()->getId() . '_' . $email->getId(); $user_token = defined('SANDBOX_URL') ? logged_user()->getTwistedToken() : ''; $content = ""; if ($remove_images) { $content = '<div id="'.$genid.'showImagesLink" style="background-color:#FFFFCC">'.lang('images are blocked').' <a href="#" onclick="og.showMailImages(\''.$pre.'\', \''.gen_id().'\', \''.$genid.'\', \''.$user_token.'\');" style="text-decoration: underline;">'.lang('show images').'</a> </div>'; } if ($remove_images && $remove_quoted) { $tpre = "iq_" . $pre;
echo lang('auto detect user timezone'); ?> </span> <div id ="<?php echo $genid; ?> detectTimeZone"> <?php echo yes_no_widget('user[autodetect_time_zone]', 'userFormAutoDetectTimezone', user_config_option('autodetect_time_zone', null, $user->getId()), lang('yes'), lang('no'), null, array('onclick' => "og.showSelectTimezone('{$genid}')")); ?> </div> <div id="<?php echo $genid; ?> selecttzdiv" <?php if (user_config_option('autodetect_time_zone', null, $user->getId())) { echo 'style="display:none"'; } ?> > <?php echo select_timezone_widget('user[timezone]', array_var($user_data, 'timezone'), array('id' => 'userFormTimezone', 'class' => 'long', 'tabindex' => '600')); ?> </div> <script type="text/javascript"> og.showSelectTimezone = function(genid) { check = document.getElementById("userFormAutoDetectTimezoneYes"); div = document.getElementById(genid + "selecttzdiv"); if (check.checked){
<td id="ie_scrollbar_adjust" style="width:0px;"></td> </tr> </table> </div><!--calowner --> </div><!--gridcontainer --> </div> </td> </tr> </table> </td> </tr></table> </div> </div> <?php $wdst = user_config_option('work_day_start_time'); $h_m = explode(':', $wdst); if (str_ends_with($wdst, 'PM')) { $h_m[0] = ($h_m[0] + 12) % 24; $h_m[1] = substr($h_m[1], 0, strpos(' ', $h_m[1])); } $defaultScrollTo = PX_HEIGHT * ($h_m[0] + $h_m[1] / 60); ?> <script> // Top Toolbar ogCalendarUserPreferences = Ext.util.JSON.decode(document.getElementById('hfCalUserPreferences').value); var ogCalTT = new og.CalendarTopToolbar({ renderTo:'calendarPanelTopToolbar' }); var ogCalSecTT = new og.CalendarSecondTopToolbar({
scripts: true }); }, wsch); </script> <?php if ($object->isNew() || $object->canLinkObject(logged_user(), $project)) { ?> <div style="display:none" id="<?php echo $genid; ?> add_linked_objects_div"> <fieldset> <?php $show_help_option = user_config_option('show_context_help'); if ($show_help_option == 'always' || $show_help_option == 'until_close' && user_config_option('show_add_note_linked_object_context_help', true, logged_user()->getId())) { ?> <div id="addNotesPanelContextHelp" class="contextHelpStyle"> <?php render_context_help($this, 'chelp add note linked objects', 'add_note_linked_object'); ?> </div> <?php } ?> <legend><?php echo lang('linked objects'); ?> </legend> <?php echo render_object_link_form($object);
/** * Returns a list of emails according to the requested parameters * * @param string $tag * @param array $attributes * @param Project $project * @return array */ function getEmails($account_id = null, $state = null, $read_filter = "", $classif_filter = "", $context = null, $start = null, $limit = null, $order_by = 'received_date', $dir = 'ASC', $join_params = null, $archived = false) { $mailTablePrefix = "e"; if (!$limit) $limit = user_config_option('mails_per_page') ? user_config_option('mails_per_page') : config_option('files_per_page'); $accountConditions = ""; // Check for accounts $accountConditions = ''; if (isset($account_id) && $account_id > 0) { //Single account $accountConditions = " AND $mailTablePrefix.account_id = " . DB::escape($account_id); } else { // show emails from other accounts $macs = MailAccountContacts::instance()->getByContact(logged_user()); $acc_ids = array(0); foreach ($macs as $mac) $acc_ids[] = $mac->getAccountId(); // permission conditions $pgs = ContactPermissionGroups::getPermissionGroupIdsByContactCSV(logged_user()->getId()); if (trim($pgs == '')) $pgs = '0'; $perm_sql = "(SELECT count(*) FROM ".TABLE_PREFIX."sharing_table st WHERE st.object_id = $mailTablePrefix.object_id AND st.group_id IN ($pgs)) > 0"; // show mails for all visible accounts and classified mails where logged_user has permissions $accountConditions = " AND ($mailTablePrefix.account_id IN (" . implode(",", $acc_ids) . ") OR $perm_sql)"; } // Check for unclassified emails $classified = ''; if ($classif_filter != '' && $classif_filter != 'all') { $classified = "AND " . ($classif_filter == 'unclassified' ? "NOT " : ""); $classified .= "o.id IN (SELECT object_id FROM ".TABLE_PREFIX."object_members)"; } // Check for draft, junk, etc. emails if ($state == "draft") { $stateConditions = " $mailTablePrefix.state = '2'"; } else if ($state == "sent") { $stateConditions = " $mailTablePrefix.state IN ('1','3','5')"; } else if ($state == "received") { $stateConditions = " $mailTablePrefix.state IN ('0','5')"; } else if ($state == "junk") { $stateConditions = " $mailTablePrefix.state = '4'"; } else if ($state == "outbox") { $stateConditions = " $mailTablePrefix.state >= 200"; } else { $stateConditions = ""; } // Check read emails if ($read_filter != "" && $read_filter != "all") { if ($read_filter == "unread") { $read = "AND NOT "; $subread = "AND NOT mc."; } else { $read = "AND "; $subread = "AND mc."; } $read2 = "id IN (SELECT rel_object_id FROM " . TABLE_PREFIX . "read_objects t WHERE contact_id = " . logged_user()->getId() . " AND t.is_read = '1')"; $read .= $read2; $subread .= $read2; } else { $read = ""; $subread = ""; } // Conversations not allowed yet //if (user_config_option('show_emails_as_conversations')) { // $state_conv_cond_1 = $state != 'received' ? " $stateConditions AND " : " m.state <> '2' AND "; // $state_conv_cond_2 = $state != 'received' ? " AND (mc.state = '1' OR mc.state = '3' OR mc.state = '5') " : " AND mc.state <> '2' "; // $archived_by_id = $archived ? "AND o.archived_by_id != 0" : "AND o.archived_by_id = 0"; // $trashed_by_id = "AND o.trashed_by_id = 0"; // $conversation_cond = "AND IF(m.conversation_id = 0, $stateConditions, $state_conv_cond_1 NOT EXISTS (SELECT * FROM ".TABLE_PREFIX."mail_contents mc WHERE m.conversation_id = mc.conversation_id AND m.account_id = mc.account_id AND m.received_date < mc.received_date $archived_by_id AND mc.is_deleted = 0 $trashed_by_id $subread $state_conv_cond_2))"; // $box_cond = "AND IF(EXISTS(SELECT * FROM ".TABLE_PREFIX."mail_contents mc WHERE m.conversation_id = mc.conversation_id AND m.object_id <> o.id AND m.account_id = mc.account_id $archived_by_id AND mc.is_deleted = 0 $trashed_by_id AND $stateConditions), TRUE, $stateConditions)"; //} else { $conversation_cond = ""; $box_cond = "AND $stateConditions"; //} /*return self::findByContext(array('limit' => $limit, 'offset' => $start, 'order' => "$order_by $dir", 'extra_conditions' => "$accountConditions $classified $read $conversation_cond $box_cond")); */ return self::instance()->listing(array( 'limit' => $limit, 'start' => $start, 'order' => $order_by, 'order_dir' => $dir, 'extra_conditions' => "$accountConditions $classified $read $conversation_cond $box_cond", //'count_results' => false, 'join_params' => $join_params )); }
</fieldset> </div> <div id="trap8"><fieldset id="fs8" style="height:0px;border:0px;padding:0px;display:none"><span style="color:#FFFFFF;"></span></fieldset></div> <?php } // if ?> <div id="<?php echo $genid; ?> add_event_invitation_div" style="display:none" class="og-add-subscribers"> <fieldset id="emailNotification"> <?php $show_help_option = user_config_option('show_context_help'); if ($show_help_option == 'always' || $show_help_option == 'until_close' && user_config_option('show_add_event_invitation_context_help', true, logged_user()->getId())) { ?> <div id="addEventPanelContextHelp" class="contextHelpStyle"> <?php render_context_help($this, 'chelp add event invitation', 'add_event_invitation'); ?> </div> <?php } ?> <legend><?php echo lang('event invitations'); ?> </legend> <?php // ComboBox for Assistance confirmation
$dtv = DateTimeValueLib::make(0, 0, 0, $month, $day_of_month, $year); } else { if ($day_of_month == $lastday + 1) { $month++; if ($month == 13) { $month = 1; $year++; } } $p = get_url('event', 'viewdate', array('day' => $day_of_month - $lastday, 'month' => $month, 'year' => $year, 'view_type' => 'viewdate')); $t = get_url('event', 'add', array('day' => $day_of_month - $lastday, 'month' => $month, 'year' => $year)); $w = $day_of_month - $lastday; $dtv = DateTimeValueLib::make(0, 0, 0, $month, $w, $year); } $loc = Localization::instance(); $start_value = $dtv->format(user_config_option('date_format')); $popupTitle = lang('add event'); $output .= "><div style='z-index:0; min-height:100px; height:100%;cursor:pointer' onclick=\"og.EventPopUp.show(null, {caller:'overview-panel', day:'" . $dtv->getDay() . "', month:'" . $dtv->getMonth() . "', year:'" . $dtv->getYear() . "', type_id:1, hour:'9', minute:'0', durationhour:1, durationmin:0, start_value: '{$start_value}', start_time:'9:00', title:'" . format_datetime($dtv, 'l, j F', logged_user()->getTimezone()) . "', view: 'week', title: '{$popupTitle}', time_format: '{$timeformat}', hide_calendar_toolbar: 0, genid:{$genid}, otype:" . $event->manager()->getObjectTypeId() . "},'');\") >\n\t\t\t<div class='{$daytitle}' style='text-align:right'>"; //if($day_of_month >= 1){ $output .= "<a class='internalLink' href=\"{$p}\" onclick=\"og.disableEventPropagation(event);\" style='color:#5B5B5B' >{$w}</a>"; // only display this link if the user has permission to add an event if (!active_project() || ProjectEvent::canAdd(logged_user(), active_project())) { // if single digit, add a zero $dom = $day_of_month; if ($dom < 10) { $dom = "0" . $dom; } // make sure user is allowed to edit the past } //}else $output .= " "; $output .= "</div>";
function get_rendered_member_selectors() { $object_members = array(); $objectId = 0; if (get_id()) { $object = Objects::findObject(get_id()); $object_type_id = $object->manager()->getObjectTypeId(); $object_members = $object->getMemberIds(); $objectId = get_id(); } else { $object_type_id = array_var($_GET, 'objtypeid'); if (array_var($_GET, 'members')) { $object_members = explode(',', array_var($_GET, 'members')); } } if (count($object_members) == 0) { $object_members = active_context_members(false); } $genid = array_var($_GET, 'genid'); $listeners = array(); //ob_start — Turn on output buffering //no output is sent from the script (other than headers), instead the output is stored in an internal buffer. ob_start(); //get skipped dimensions for this view $view_name = array_var($_GET, 'view_name'); $dimensions_to_show = explode(",", user_config_option($view_name . "_view_dimensions_combos")); $dimensions_to_skip = array_diff(get_user_dimensions_ids(), $dimensions_to_show); render_member_selectors($object_type_id, $genid, $object_members, array('listeners' => $listeners), $dimensions_to_skip, null, false); ajx_current("empty"); //Gets the current buffer contents and delete current output buffer. //ob_get_clean() essentially executes both ob_get_contents() and ob_end_clean(). ajx_extra_data(array("htmlToAdd" => ob_get_clean())); ajx_extra_data(array("objectId" => $objectId)); }
/** * Execute a report and return results * * @param $id * @param $params * * @return array */ static function executeReport($id, $params, $order_by_col = '', $order_by_asc = true, $offset = 0, $limit = 50, $to_print = false) { if (is_null(active_context())) { CompanyWebsite::instance()->setContext(build_context_array(array_var($_REQUEST, 'context'))); } $results = array(); $report = self::getReport($id); $show_archived = false; if ($report instanceof Report) { $conditionsFields = ReportConditions::getAllReportConditionsForFields($id); $conditionsCp = ReportConditions::getAllReportConditionsForCustomProperties($id); $ot = ObjectTypes::findById($report->getReportObjectTypeId()); $table = $ot->getTableName(); if ($ot->getType() == 'dimension_object' || $ot->getType() == 'dimension_group') { $hook_parameters = array('report' => $report, 'params' => $params, 'order_by_col' => $order_by_col, 'order_by_asc' => $order_by_asc, 'offset' => $offset, 'limit' => $limit, 'to_print' => $to_print); $report_result = null; Hook::fire('replace_execute_report_function', $hook_parameters, $report_result); if ($report_result) { return $report_result; } } eval('$managerInstance = ' . $ot->getHandlerClass() . "::instance();"); eval('$item_class = ' . $ot->getHandlerClass() . '::instance()->getItemClass(); $object = new $item_class();'); $order_by = ''; if (is_object($params)) { $params = get_object_vars($params); } $report_columns = ReportColumns::getAllReportColumns($id); $allConditions = ""; $contact_extra_columns = self::get_extra_contact_columns(); if (count($conditionsFields) > 0) { foreach ($conditionsFields as $condField) { if ($condField->getFieldName() == "archived_on") { $show_archived = true; } $skip_condition = false; $model = $ot->getHandlerClass(); $model_instance = new $model(); $col_type = $model_instance->getColumnType($condField->getFieldName()); $allConditions .= ' AND '; $dateFormat = 'm/d/Y'; if (isset($params[$condField->getId()])) { $value = $params[$condField->getId()]; if ($col_type == DATA_TYPE_DATE || $col_type == DATA_TYPE_DATETIME) { $dateFormat = user_config_option('date_format'); } } else { $value = $condField->getValue(); } if ($ot->getHandlerClass() == 'Contacts' && in_array($condField->getFieldName(), $contact_extra_columns)) { $allConditions .= self::get_extra_contact_column_condition($condField->getFieldName(), $condField->getCondition(), $value); } else { if ($value == '' && $condField->getIsParametrizable()) { $skip_condition = true; } if (!$skip_condition) { $field_name = $condField->getFieldName(); if (in_array($condField->getFieldName(), Objects::getColumns())) { $field_name = 'o`.`' . $condField->getFieldName(); } if ($condField->getCondition() == 'like' || $condField->getCondition() == 'not like') { $value = '%' . $value . '%'; } if ($col_type == DATA_TYPE_DATE || $col_type == DATA_TYPE_DATETIME) { if ($value == date_format_tip($dateFormat)) { $value = EMPTY_DATE; } else { $dtValue = DateTimeValueLib::dateFromFormatAndString($dateFormat, $value); $value = $dtValue->format('Y-m-d'); } } if ($condField->getCondition() != '%') { if ($col_type == DATA_TYPE_INTEGER || $col_type == DATA_TYPE_FLOAT) { $allConditions .= '`' . $field_name . '` ' . $condField->getCondition() . ' ' . DB::escape($value); } else { if ($condField->getCondition() == '=' || $condField->getCondition() == '<=' || $condField->getCondition() == '>=') { if ($col_type == DATA_TYPE_DATETIME || $col_type == DATA_TYPE_DATE) { $equal = 'datediff(' . DB::escape($value) . ', `' . $field_name . '`)=0'; } else { $equal = '`' . $field_name . '` ' . $condField->getCondition() . ' ' . DB::escape($value); } switch ($condField->getCondition()) { case '=': $allConditions .= $equal; break; case '<=': case '>=': $allConditions .= '(`' . $field_name . '` ' . $condField->getCondition() . ' ' . DB::escape($value) . ' OR ' . $equal . ') '; break; } } else { $allConditions .= '`' . $field_name . '` ' . $condField->getCondition() . ' ' . DB::escape($value); } } } else { $allConditions .= '`' . $field_name . '` like ' . DB::escape("%{$value}"); } } else { $allConditions .= ' true'; } } } } if (count($conditionsCp) > 0) { $dateFormat = user_config_option('date_format'); $date_format_tip = date_format_tip($dateFormat); foreach ($conditionsCp as $condCp) { $cp = CustomProperties::getCustomProperty($condCp->getCustomPropertyId()); $skip_condition = false; if (isset($params[$condCp->getId() . "_" . $cp->getName()])) { $value = $params[$condCp->getId() . "_" . $cp->getName()]; } else { $value = $condCp->getValue(); } if ($value == '' && $condCp->getIsParametrizable()) { $skip_condition = true; } if (!$skip_condition) { $current_condition = ' AND '; $current_condition .= 'o.id IN ( SELECT object_id as id FROM ' . TABLE_PREFIX . 'custom_property_values cpv WHERE '; $current_condition .= ' cpv.custom_property_id = ' . $condCp->getCustomPropertyId(); $fieldType = $object->getColumnType($condCp->getFieldName()); if ($condCp->getCondition() == 'like' || $condCp->getCondition() == 'not like') { $value = '%' . $value . '%'; } if ($cp->getType() == 'date') { if ($value == $date_format_tip) { continue; } $dtValue = DateTimeValueLib::dateFromFormatAndString($dateFormat, $value); $value = $dtValue->format('Y-m-d H:i:s'); } if ($condCp->getCondition() != '%') { if ($cp->getType() == 'numeric') { $current_condition .= ' AND cpv.value ' . $condCp->getCondition() . ' ' . DB::escape($value); } else { if ($cp->getType() == 'boolean') { $current_condition .= ' AND cpv.value ' . $condCp->getCondition() . ' ' . ($value ? '1' : '0'); if (!$value) { $current_condition .= ') OR o.id NOT IN (SELECT object_id as id FROM ' . TABLE_PREFIX . 'custom_property_values cpv2 WHERE cpv2.object_id=o.id AND cpv2.value=1 AND cpv2.custom_property_id = ' . $condCp->getCustomPropertyId(); } } else { $current_condition .= ' AND cpv.value ' . $condCp->getCondition() . ' ' . DB::escape($value); } } } else { $current_condition .= ' AND cpv.value like ' . DB::escape("%{$value}"); } $current_condition .= ')'; $allConditions .= $current_condition; } } } $select_columns = array('*'); $join_params = null; if ($order_by_col == '') { $order_by_col = $report->getOrderBy(); } if ($ot->getHandlerClass() == 'Contacts' && in_array($order_by_col, $contact_extra_columns)) { $join_params = self::get_extra_contact_column_order_by($order_by_col, $order_by_col, $select_columns); } $original_order_by_col = $order_by_col; if (in_array($order_by_col, self::$external_columns)) { $order_by_col = 'name_order'; $join_params = array('table' => Objects::instance()->getTableName(), 'jt_field' => 'id', 'e_field' => $original_order_by_col, 'join_type' => 'left'); $select_columns = array(); $tmp_cols = $managerInstance->getColumns(); foreach ($tmp_cols as $col) { $select_columns[] = "e.{$col}"; } $tmp_cols = Objects::instance()->getColumns(); foreach ($tmp_cols as $col) { $select_columns[] = "o.{$col}"; } $select_columns[] = 'jt.name as name_order'; } if ($order_by_asc == null) { $order_by_asc = $report->getIsOrderByAsc(); } if ($ot->getName() == 'task' && !SystemPermissions::userHasSystemPermission(logged_user(), 'can_see_assigned_to_other_tasks')) { $allConditions .= " AND assigned_to_contact_id = " . logged_user()->getId(); } if ($managerInstance) { if ($order_by_col == "order") { $order_by_col = "`{$order_by_col}`"; } $listing_parameters = array("select_columns" => $select_columns, "order" => "{$order_by_col}", "order_dir" => $order_by_asc ? "ASC" : "DESC", "extra_conditions" => $allConditions, "count_results" => true, "join_params" => $join_params); if ($limit > 0) { $listing_parameters["start"] = $offset; $listing_parameters["limit"] = $limit; } if ($show_archived) { $listing_parameters["archived"] = true; } $result = $managerInstance->listing($listing_parameters); } else { // TODO Performance Killer $result = ContentDataObjects::getContentObjects(active_context(), $ot, $order_by_col, $order_by_asc ? "ASC" : "DESC", $allConditions); } $objects = $result->objects; $totalResults = $result->total; $results['pagination'] = Reports::getReportPagination($id, $params, $original_order_by_col, $order_by_asc, $offset, $limit, $totalResults); $dimensions_cache = array(); foreach ($report_columns as $column) { if ($column->getCustomPropertyId() == 0) { $field = $column->getFieldName(); if (str_starts_with($field, 'dim_')) { $dim_id = str_replace("dim_", "", $field); $dimension = Dimensions::getDimensionById($dim_id); $dimensions_cache[$dim_id] = $dimension; $column_name = $dimension->getName(); $results['columns'][$field] = $column_name; $results['db_columns'][$column_name] = $field; } else { if ($managerInstance->columnExists($field) || Objects::instance()->columnExists($field)) { $column_name = Localization::instance()->lang('field ' . $ot->getHandlerClass() . ' ' . $field); if (is_null($column_name)) { $column_name = lang('field Objects ' . $field); } $results['columns'][$field] = $column_name; $results['db_columns'][$column_name] = $field; } else { if ($ot->getHandlerClass() == 'Contacts') { if (in_array($field, $contact_extra_columns)) { $results['columns'][$field] = lang($field); $results['db_columns'][lang($field)] = $field; } } else { if ($ot->getHandlerClass() == 'Timeslots') { if (in_array($field, array('time', 'billing'))) { $results['columns'][$field] = lang('field Objects ' . $field); $results['db_columns'][lang('field Objects ' . $field)] = $field; } } else { if ($ot->getHandlerClass() == 'MailContents') { if (in_array($field, array('to', 'cc', 'bcc', 'body_plain', 'body_html'))) { $results['columns'][$field] = lang('field Objects ' . $field); $results['db_columns'][lang('field Objects ' . $field)] = $field; } } } } } } } else { $results['columns'][$column->getCustomPropertyId()] = $column->getCustomPropertyId(); } } $report_rows = array(); foreach ($objects as &$object) { /* @var $object Object */ $obj_name = $object->getObjectName(); $icon_class = $object->getIconClass(); $row_values = array('object_type_id' => $object->getObjectTypeId()); if (!$to_print) { $row_values['link'] = '<a class="link-ico ' . $icon_class . '" title="' . clean($obj_name) . '" target="new" href="' . $object->getViewUrl() . '"> </a>'; } foreach ($report_columns as $column) { if ($column->getCustomPropertyId() == 0) { $field = $column->getFieldName(); if (str_starts_with($field, 'dim_')) { $dim_id = str_replace("dim_", "", $field); if (!array_var($dimensions_cache, $dim_id) instanceof Dimension) { $dimension = Dimensions::getDimensionById($dim_id); $dimensions_cache[$dim_id] = $dimension; } else { $dimension = array_var($dimensions_cache, $dim_id); } $om_object_id = $object instanceof Timeslot ? $object->getRelObjectId() : $object->getId(); $members = ObjectMembers::getMembersByObjectAndDimension($om_object_id, $dim_id, " AND om.is_optimization=0"); $value = ""; foreach ($members as $member) { /* @var $member Member */ $val = $member->getPath(); $val .= ($val == "" ? "" : "/") . $member->getName(); if ($value != "") { $val = " - {$val}"; } $value .= $val; } $row_values[$field] = $value; } else { if ($object instanceof Timeslot) { if ($field == 'id') { $value = $object->getObjectId(); } else { $value = $object->getColumnValue($field); // if it is a task column if (in_array($field, ProjectTasks::instance()->getColumns())) { $task = ProjectTasks::findById($object->getRelObjectId()); // if task exists if ($task instanceof ProjectTask) { $value = $task->getColumnValue($field); // if it is an external task column if (in_array($field, ProjectTasks::instance()->getExternalColumns())) { $value = self::instance()->getExternalColumnValue($field, $value, ProjectTasks::instance()); } else { // if is a date then use format if (ProjectTasks::instance()->getColumnType($field) == DATA_TYPE_DATETIME && $value instanceof DateTimeValue) { $value = format_value_to_print($field, $value->toMySQL(), DATA_TYPE_DATETIME, $report->getReportObjectTypeId()); } } } $results['columns'][$field] = lang('field ProjectTasks ' . $field); $results['db_columns'][lang('field ProjectTasks ' . $field)] = $field; } } } else { $value = $object->getColumnValue($field); } if ($value instanceof DateTimeValue) { $dateFormat = user_config_option('date_format'); Hook::fire("custom_property_date_format", null, $dateFormat); $tz = logged_user()->getTimezone(); if ($object instanceof ProjectTask) { if ($field == 'due_date' && !$object->getUseDueTime() || $field == 'start_date' && !$object->getUseStartTime()) { $dateFormat = user_config_option('date_format'); $tz = 0; } } $value = format_date($value, $dateFormat, $tz * 3600); } if (in_array($field, $managerInstance->getExternalColumns())) { if ($object instanceof Timeslot && $field == 'time') { $lastStop = $object->getEndTime() != null ? $object->getEndTime() : ($object->isPaused() ? $object->getPausedOn() : DateTimeValueLib::now()); $seconds = $lastStop->getTimestamp() - $object->getStartTime()->getTimestamp(); $hours = number_format($seconds / 3600, 2, ',', '.'); $value = $hours; //$value = DateTimeValue::FormatTimeDiff($object->getStartTime(), $lastStop, "hm", 60, $object->getSubtract()); } else { if ($object instanceof Timeslot && $field == 'billing') { $value = config_option('currency_code', '$') . ' ' . $object->getFixedBilling(); } else { $value = self::instance()->getExternalColumnValue($field, $value, $managerInstance); } } } else { if ($field != 'link') { //$value = html_to_text(html_entity_decode($value)); if ($object->getColumnType($field) == DATA_TYPE_STRING) { // change html block end tags and brs to \n, then remove all other html tags, then replace \n with <br>, to remove all styles and keep the enters $value = str_replace(array("</div>", "</p>", "<br>", "<br />", "<br/>"), "\n", $value); $value = nl2br(strip_tags($value)); } } } if (self::isReportColumnEmail($value)) { if (logged_user()->hasMailAccounts()) { $value = '<a class="internalLink" href="' . get_url('mail', 'add_mail', array('to' => clean($value))) . '">' . clean($value) . '</a></div>'; } else { $value = '<a class="internalLink" target="_self" href="mailto:' . clean($value) . '">' . clean($value) . '</a></div>'; } } $row_values[$field] = $value; if ($ot->getHandlerClass() == 'Contacts') { if ($managerInstance instanceof Contacts) { $contact = Contacts::findOne(array("conditions" => "object_id = " . $object->getId())); if ($field == "email_address") { $row_values[$field] = $contact->getEmailAddress(); } if ($field == "is_user") { $row_values[$field] = $contact->getUserType() > 0 && !$contact->getIsCompany(); } if ($field == "im_values") { $str = ""; foreach ($contact->getAllImValues() as $type => $value) { $str .= ($str == "" ? "" : " | ") . "{$type}: {$value}"; } $row_values[$field] = $str; } if (in_array($field, array("mobile_phone", "work_phone", "home_phone"))) { if ($field == "mobile_phone") { $row_values[$field] = $contact->getPhoneNumber('mobile', null, false); } else { if ($field == "work_phone") { $row_values[$field] = $contact->getPhoneNumber('work', null, false); } else { if ($field == "home_phone") { $row_values[$field] = $contact->getPhoneNumber('home', null, false); } } } } if (in_array($field, array("personal_webpage", "work_webpage", "other_webpage"))) { if ($field == "personal_webpage") { $row_values[$field] = $contact->getWebpageUrl('personal'); } else { if ($field == "work_webpage") { $row_values[$field] = $contact->getWebpageUrl('work'); } else { if ($field == "other_webpage") { $row_values[$field] = $contact->getWebpageUrl('other'); } } } } if (in_array($field, array("home_address", "work_address", "other_address"))) { if ($field == "home_address") { $row_values[$field] = $contact->getStringAddress('home'); } else { if ($field == "work_address") { $row_values[$field] = $contact->getStringAddress('work'); } else { if ($field == "other_address") { $row_values[$field] = $contact->getStringAddress('other'); } } } } } } else { if ($ot->getHandlerClass() == 'MailContents') { if (in_array($field, array('to', 'cc', 'bcc', 'body_plain', 'body_html'))) { $mail_data = MailDatas::findById($object->getId()); $row_values[$field] = $mail_data->getColumnValue($field); if ($field == "body_html") { if (class_exists("DOMDocument")) { $d = new DOMDocument(); $mock = new DOMDocument(); $d->loadHTML(remove_css_and_scripts($row_values[$field])); $body = $d->getElementsByTagName('body')->item(0); foreach ($body->childNodes as $child) { $mock->appendChild($mock->importNode($child, true)); } // if css is inside an html comment => remove it $row_values[$field] = preg_replace('/<!--(.*)-->/Uis', '', remove_css($row_values[$field])); } else { $row_values[$field] = preg_replace('/<!--(.*)-->/Uis', '', remove_css_and_scripts($row_values[$field])); } } } } } if (!$to_print && $field == "name") { $row_values[$field] = '<a target="new-' . $object->getId() . '" href="' . $object->getViewUrl() . '">' . $value . '</a>'; } } } else { $colCp = $column->getCustomPropertyId(); $cp = CustomProperties::getCustomProperty($colCp); if ($cp instanceof CustomProperty) { /* @var $cp CustomProperty */ $row_values[$cp->getName()] = get_custom_property_value_for_listing($cp, $object); $results['columns'][$colCp] = $cp->getName(); $results['db_columns'][$cp->getName()] = $colCp; } } } Hook::fire("report_row", $object, $row_values); $report_rows[] = $row_values; } if (!$to_print) { if (is_array($results['columns'])) { array_unshift($results['columns'], ''); } else { $results['columns'] = array(''); } Hook::fire("report_header", $ot, $results['columns']); } $results['rows'] = $report_rows; } return $results; }
} if ($mod_username == "") { $mod_username = lang('CAL_ANONYMOUS'); } // if the event is private and the user is anonymous, return that the event does not exist. if ($error == "") { $error = lang('CAL_DOESNT_EXIST'); } $durtime = $event->getDuration()->getTimestamp() - $start_time->getTimestamp(); $durmin = $durtime / 60 % 60; //seconds per minute $durhr = $durtime / 3600 % 24; //seconds per hour $durday = floor($durtime / 86400); //seconds per day if (user_config_option('time_format_use_24')) { $timeformat = 'G:i'; } else { $timeformat = 'g:i A'; } $time = format_time($start_time, $timeformat); // organize duration of event $duration = ''; if ($durday > 0) { $duration .= $durday . ' ' . lang('days') . ($durhr != "1" ? ', ' : ' '); } $duration .= $durhr . ' '; if ($durhr != "1") { $duration .= lang('CAL_HOURS'); } else { $duration .= lang('CAL_HOUR');
function edit_custom_report() { if (logged_user()->isGuest()) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $report_id = array_var($_GET, 'id'); $report = Reports::getReport($report_id); if (!$report->canEdit(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if if (is_array(array_var($_POST, 'report'))) { try { ajx_current("empty"); $report_data = array_var($_POST, 'report'); DB::beginWork(); $report->setName($report_data['name']); $report->setDescription($report_data['description']); $report->setObjectType($report_data['object_type']); $report->setOrderBy($report_data['order_by']); $report->setIsOrderByAsc($report_data['order_by_asc'] == 'asc'); $report->save(); $conditions = array_var($_POST, 'conditions'); if (!is_array($conditions)) { $conditions = array(); } foreach ($conditions as $condition) { $newCondition = new ReportCondition(); if ($condition['id'] > 0) { $newCondition = ReportConditions::getCondition($condition['id']); } if ($condition['deleted'] == "1") { $newCondition->delete(); continue; } $newCondition->setReportId($report_id); $custom_prop_id = isset($condition['custom_property_id']) ? $condition['custom_property_id'] : 0; $newCondition->setCustomPropertyId($custom_prop_id); $newCondition->setFieldName($condition['field_name']); $newCondition->setCondition($condition['condition']); if ($condition['field_type'] == 'boolean') { $newCondition->setValue(isset($condition['value']) && $condition['value']); } else { if ($condition['field_type'] == 'date') { if ($condition['value'] == '') { $newCondition->setValue(''); } else { $dtFromWidget = DateTimeValueLib::dateFromFormatAndString(user_config_option('date_format'), $condition['value']); $newCondition->setValue(date("m/d/Y", $dtFromWidget->getTimestamp())); } } else { $newCondition->setValue(isset($condition['value']) ? $condition['value'] : ''); } } $newCondition->setIsParametrizable(isset($condition['is_parametrizable'])); $newCondition->save(); } ReportColumns::delete('report_id = ' . $report_id); $columns = array_var($_POST, 'columns'); asort($columns); //sort the array by column order foreach ($columns as $column => $order) { if ($order > 0) { $newColumn = new ReportColumn(); $newColumn->setReportId($report_id); if (is_numeric($column)) { $newColumn->setCustomPropertyId($column); } else { $newColumn->setFieldName($column); } $newColumn->save(); } } DB::commit(); flash_success(lang('custom report updated')); ajx_current('back'); } catch (Exception $e) { DB::rollback(); flash_error($e->getMessage()); ajx_current("empty"); } // try } else { $this->setTemplate('add_custom_report'); tpl_assign('url', get_url('reporting', 'edit_custom_report', array('id' => $report_id))); if ($report instanceof Report) { tpl_assign('id', $report_id); $report_data = array('name' => $report->getName(), 'description' => $report->getDescription(), 'object_type' => $report->getObjectType(), 'order_by' => $report->getOrderBy(), 'order_by_asc' => $report->getIsOrderByAsc(), 'workspace' => $report->getWorkspace(), 'tags' => $report->getTags()); tpl_assign('report_data', $report_data); $conditions = ReportConditions::getAllReportConditions($report_id); tpl_assign('conditions', $conditions); $columns = ReportColumns::getAllReportColumns($report_id); $colIds = array(); foreach ($columns as $col) { if ($col->getCustomPropertyId() > 0) { $colIds[] = $col->getCustomPropertyId(); } else { $colIds[] = $col->getFieldName(); } } tpl_assign('columns', $colIds); } $selected_type = $report->getObjectType(); $types = array(array("", lang("select one")), array("Companies", lang("companies")), array("Contacts", lang("contacts")), array("MailContents", lang("email type")), array("ProjectEvents", lang("events")), array("ProjectFiles", lang("file")), array("ProjectMilestones", lang("milestone")), array("ProjectMessages", lang("message")), array("ProjectTasks", lang("task")), array("Users", lang("user")), array("ProjectWebpages", lang("webpage")), array("Projects", lang("workspace"))); tpl_assign('object_types', $types); tpl_assign('selected_type', $selected_type); tpl_assign('allowed_columns', $this->get_allowed_columns($selected_type), true); } }
function get_dimension_object_fields() { ajx_current("empty"); if (!can_manage_dimension_members(logged_user())) { flash_error(lang('no access permissions')); return; } $object_type = ObjectTypes::findById(get_id()); if (!$object_type instanceof ObjectType) { flash_error(lang('object type dnx')); return; } $handler_class = $object_type->getHandlerClass(); eval('$fields = ' . $handler_class . '::getPublicColumns();'); if (get_id('mem_id') > 0) { $date_format = user_config_option('date_format'); $member = Members::findById(get_id('mem_id')); if ($member instanceof Member) { $dim_obj = Objects::findObject($member->getObjectId()); } if (isset($dim_obj) && !is_null($dim_obj)) { foreach ($fields as &$field) { $value = $dim_obj->getColumnValue($field['col']); if ($field['type'] == DATA_TYPE_DATETIME && $value instanceof DateTimeValue) { $value = $value->format($date_format); } $field['val'] = $value; } } } $data = array('fields' => $fields, 'title' => lang($object_type->getName())); ajx_extra_data($data); }
function new_list_tasks() { //load config options into cache for better performance load_user_config_options_by_category_name('task panel'); // get query parameters, save user preferences if necessary $status = array_var($_GET, 'status', null); if (is_null($status) || $status == '') { $status = user_config_option('task panel status', 2); } else { if (user_config_option('task panel status') != $status) { set_user_config_option('task panel status', $status, logged_user()->getId()); } } $previous_filter = user_config_option('task panel filter', 'no_filter'); $filter = array_var($_GET, 'filter'); if (is_null($filter) || $filter == '') { $filter = $previous_filter; } else { if ($previous_filter != $filter) { set_user_config_option('task panel filter', $filter, logged_user()->getId()); } } if ($filter != 'no_filter') { $filter_value = array_var($_GET, 'fval'); if (is_null($filter_value) || $filter_value == '') { $filter_value = user_config_option('task panel filter value', null, logged_user()->getId()); set_user_config_option('task panel filter value', $filter_value, logged_user()->getId()); $filter = $previous_filter; set_user_config_option('task panel filter', $filter, logged_user()->getId()); } else { if (user_config_option('task panel filter value') != $filter_value) { set_user_config_option('task panel filter value', $filter_value, logged_user()->getId()); } } } $isJson = array_var($_GET, 'isJson', false); if ($isJson) { ajx_current("empty"); } $template_condition = "`is_template` = 0 "; //Get the task query conditions $task_filter_condition = ""; switch ($filter) { case 'assigned_to': $assigned_to = $filter_value; if ($assigned_to > 0) { $task_filter_condition = " AND (`assigned_to_contact_id` = " . $assigned_to . ") "; } else { if ($assigned_to == -1) { $task_filter_condition = " AND `assigned_to_contact_id` = 0"; } } break; case 'assigned_by': if ($filter_value != 0) { $task_filter_condition = " AND `assigned_by_id` = " . $filter_value . " "; } break; case 'created_by': if ($filter_value != 0) { $task_filter_condition = " AND `created_by_id` = " . $filter_value . " "; } break; case 'completed_by': if ($filter_value != 0) { $task_filter_condition = " AND `completed_by_id` = " . $filter_value . " "; } break; case 'milestone': $task_filter_condition = " AND `milestone_id` = " . $filter_value . " "; break; case 'priority': $task_filter_condition = " AND `priority` = " . $filter_value . " "; break; case 'subtype': if ($filter_value != 0) { $task_filter_condition = " AND `object_subtype` = " . $filter_value . " "; } break; case 'no_filter': $task_filter_condition = ""; break; default: flash_error(lang('task filter criteria not recognised', $filter)); } $task_status_condition = ""; $now = DateTimeValueLib::now()->format('Y-m-j 00:00:00'); switch ($status) { case 0: // Incomplete tasks $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME); break; case 1: // Complete tasks $task_status_condition = " AND `completed_on` > " . DB::escape(EMPTY_DATETIME); break; case 10: // Active tasks $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `start_date` <= '{$now}'"; break; case 11: // Overdue tasks $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` < '{$now}'"; break; case 12: // Today tasks $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` = '{$now}'"; break; case 13: // Today + Overdue tasks $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` <= '{$now}'"; break; case 14: // Today + Overdue tasks $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `due_date` <= '{$now}'"; break; case 20: // Actives task by current user $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `start_date` <= '{$now}' AND `assigned_to_contact_id` = " . logged_user()->getId(); break; case 21: // Subscribed tasks by current user $res20 = DB::execute("SELECT object_id FROM " . TABLE_PREFIX . "object_subscriptions WHERE `contact_id` = " . logged_user()->getId()); $subs_rows = $res20->fetchAll($res20); foreach ($subs_rows as $row) { $subs[] = $row['object_id']; } unset($res20, $subs_rows, $row); $task_status_condition = " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " AND `id` IN(" . implode(',', $subs) . ")"; break; case 2: // All tasks break; default: throw new Exception('Task status "' . $status . '" not recognised'); } $conditions = "AND {$template_condition} {$task_filter_condition} {$task_status_condition}"; //Now get the tasks //$tasks = ProjectTasks::getContentObjects(active_context(), ObjectTypes::findById(ProjectTasks::instance()->getObjectTypeId()), null, null, $conditions,null)->objects; $tasks = ProjectTasks::instance()->listing(array("extra_conditions" => $conditions, "start" => 0, "limit" => 501, "count_results" => false))->objects; $pendingstr = $status == 0 ? " AND `completed_on` = " . DB::escape(EMPTY_DATETIME) . " " : ""; $milestone_conditions = " AND `is_template` = false " . $pendingstr; //Find all internal milestones for these tasks //$internalMilestones = ProjectMilestones::getContentObjects(active_context(), ObjectTypes::findById(ProjectMilestones::instance()->getObjectTypeId()), null, null, $milestone_conditions,null)->objects; $internalMilestones = ProjectMilestones::instance()->listing(array("extra_conditions" => $milestone_conditions))->objects; //Find all external milestones for these tasks, external milestones are the ones that belong to a parent member and have tasks in the current member $milestone_ids = array(); if ($tasks) { foreach ($tasks as $task) { if ($task->getMilestoneId() != 0) { $milestone_ids[$task->getMilestoneId()] = $task->getMilestoneId(); } } } $int_milestone_ids = array(); foreach ($internalMilestones as $milestone) { $int_milestone_ids[] = $milestone->getId(); } $milestone_ids = array_diff($milestone_ids, $int_milestone_ids); if (count($milestone_ids) == 0) { $milestone_ids[] = 0; } $ext_milestone_conditions = " `is_template` = false " . $pendingstr . ' AND `object_id` IN (' . implode(',', $milestone_ids) . ')'; $externalMilestones = ProjectMilestones::findAll(array('conditions' => $ext_milestone_conditions)); // Get Users Info $users = allowed_users_in_context(ProjectTasks::instance()->getObjectTypeId(), active_context(), ACCESS_LEVEL_READ); $allUsers = Contacts::getAllUsers(); $user_ids = array(-1); foreach ($users as $user) { $user_ids[] = $user->getId(); } // only companies with users $companies = Contacts::findAll(array("conditions" => "e.is_company = 1", "join" => array("table" => Contacts::instance()->getTableName(), "jt_field" => "object_id", "j_sub_q" => "SELECT xx.object_id FROM " . Contacts::instance()->getTableName(true) . " xx WHERE \n\t\t\t\t\txx.is_company=0 AND xx.company_id = e.object_id AND xx.object_id IN (" . implode(",", $user_ids) . ") LIMIT 1"))); tpl_assign('tasks', $tasks); if (config_option('use tasks dependencies')) { $dependency_count = array(); foreach ($tasks as $task) { $previous = 0; $ptasks = ProjectTaskDependencies::getDependenciesForTask($task->getId()); foreach ($ptasks as $pdep) { $ptask = ProjectTasks::findById($pdep->getPreviousTaskId()); if ($ptask instanceof ProjectTask && !$ptask->isCompleted()) { $previous++; } } $dependants = ProjectTaskDependencies::getDependantsForTask($task->getId()); $dep_csv = ""; foreach ($dependants as $dep) { $dep_csv .= ($dep_csv == "" ? "" : ",") . $dep->getTaskId(); } $dependency_count[] = array('id' => $task->getId(), 'count' => $previous, 'dependants' => $dep_csv); } tpl_assign('dependency_count', $dependency_count); } if (!$isJson) { $all_templates = COTemplates::findAll(array('conditions' => '`trashed_by_id` = 0 AND `archived_by_id` = 0')); tpl_assign('all_templates', $all_templates); if (user_config_option('task_display_limit') > 0 && count($tasks) > user_config_option('task_display_limit')) { tpl_assign('displayTooManyTasks', true); array_pop($tasks); } tpl_assign('object_subtypes', array()); tpl_assign('internalMilestones', $internalMilestones); tpl_assign('externalMilestones', $externalMilestones); tpl_assign('users', $users); tpl_assign('allUsers', $allUsers); tpl_assign('companies', $companies); $userPref = array(); $userPref = array('filterValue' => isset($filter_value) ? $filter_value : '', 'filter' => $filter, 'status' => $status, 'showWorkspaces' => user_config_option('tasksShowWorkspaces', 1), 'showTime' => user_config_option('tasksShowTime'), 'showDates' => user_config_option('tasksShowDates'), 'showTags' => user_config_option('tasksShowTags', 0), 'showEmptyMilestones' => user_config_option('tasksShowEmptyMilestones', 1), 'showTimeEstimates' => user_config_option('tasksShowTimeEstimates', 1), 'groupBy' => user_config_option('tasksGroupBy', 'milestone'), 'orderBy' => user_config_option('tasksOrderBy', 'priority'), 'defaultNotifyValue' => user_config_option('can notify from quick add')); hook::fire('tasks_user_preferences', null, $userPref); tpl_assign('userPreferences', $userPref); ajx_set_no_toolbar(true); } }
/** * Lists all contacts and clients * */ function list_all() { ajx_current("empty"); // Get all variables from request $start = array_var($_GET,'start', 0); $limit = array_var($_GET,'limit', config_option('files_per_page')); $page = 1; if ($start > 0){ $page = ($start / $limit) + 1; } $order = array_var($_GET,'sort'); $order_dir = array_var($_GET,'dir'); $action = array_var($_GET,'action'); $attributes = array( "ids" => explode(',', array_var($_GET, 'ids')), "types" => explode(',', array_var($_GET, 'types')), "accountId" => array_var($_GET, 'account_id'), "viewType" => array_var($_GET, 'view_type'), ); //Resolve actions to perform $actionMessage = array(); if (isset($action)) { $actionMessage = $this->resolveAction($action, $attributes); if ($actionMessage["errorCode"] == 0) { flash_success($actionMessage["errorMessage"]); } else { flash_error($actionMessage["errorMessage"]); } } $extra_conditions = ""; if(!user_config_option("viewCompaniesChecked", 1,logged_user()->getId())){ $extra_conditions = ' AND `is_company` = 0 '; } if(!user_config_option("viewContactsChecked", 1,logged_user()->getId())){ if(user_config_option("viewCompaniesChecked", 1,logged_user()->getId())){ $extra_conditions = ' AND `is_company` = 1 '; if(user_config_option("viewUsersChecked", 1,logged_user()->getId())){ $extra_conditions = ' AND `is_company` = 1 OR `user_type` != 0 '; } }else{ $extra_conditions.= ' AND `user_type` != 0 '; } } if(!user_config_option("viewUsersChecked", 1,logged_user()->getId())){ $extra_conditions.= ' AND `user_type` < 1 '; } $extra_conditions.= " AND disabled = 0 " ; switch ($order){ case 'updatedOn': $order = '`updated_on`'; break; case 'createdOn': $order = '`created_on`'; break; case 'name': $order = ' concat(surname, first_name) '; break; default: $order = '`name`'; break; } if (!$order_dir){ switch ($order){ case 'name': $order_dir = 'ASC'; break; default: $order_dir = 'DESC'; } } $content_objects = Contacts::instance()->listing(array( "order" => $order, "order_dir" => $order_dir, "extra_conditions" => $extra_conditions, "start" =>$start, "limit" => $limit )); // Prepare response object $object = $this->prepareObject($content_objects->objects, $content_objects->total, $start, $attributes); ajx_extra_data($object); tpl_assign("listing", $object); }
<?php $isUserAccount = isset($object) && $object instanceof User; if (isset($user) && $user instanceof User) { ?> <div class="card" style="padding:0px;"> <?php $show_help_option = user_config_option('show_context_help'); if ($isUserAccount && ($show_help_option == 'always' || $show_help_option == 'until_close' && user_config_option('show_account_context_help', true, logged_user()->getId()))) { ?> <div style="padding-bottom:10px;"> <?php if ($user->getId() == logged_user()->getId()) { $hd_key = 'chelp personal account'; } else { $hd_key = 'chelp user account'; if (logged_user()->isAdministrator()) { $hd_key .= ' admin'; } } render_context_help($this, $hd_key, 'account'); ?> </div> <?php } ?> <div class="cardIcon"><img src="<?php echo $user->getAvatarUrl(); ?> " alt="<?php
/** * Returns a list of emails according to the requested parameters * * @param string $tag * @param array $attributes * @param Project $project * @return array */ function getEmails($tag = null, $account_id = null, $state = null, $read_filter = "", $classif_filter = "", $project = null, $start = null, $limit = null, $order_by = 'received_date', $dir = 'ASC', $archived = false, $count = false) { // Check for accounts $accountConditions = ""; if (isset($account_id) && $account_id > 0) { //Single account $accountConditions = " AND `account_id` = " . DB::escape($account_id); } // Check for unclassified emails if ($classif_filter != '' && $classif_filter != 'all') { if ($classif_filter == 'unclassified') { $classified = "AND NOT "; } else { $classified = "AND "; } $classified .= "`id` IN (SELECT `object_id` FROM `" . TABLE_PREFIX . "workspace_objects` WHERE `object_manager` = 'MailContents')"; } else { $classified = ""; } // Check for drafts emails if ($state == "draft") { $stateConditions = " `state` = '2'"; } else { if ($state == "sent") { $stateConditions = " (`state` = '1' OR `state` = '3' OR `state` = '5')"; } else { if ($state == "received") { $stateConditions = " (`state` = '0' OR `state` = '5')"; } else { if ($state == "junk") { $stateConditions = " `state` = '4'"; } else { if ($state == "outbox") { $stateConditions = " `state` >= 200"; } else { $stateConditions = ""; } } } } } // Check read emails if ($read_filter != "" && $read_filter != "all") { if ($read_filter == "unread") { $read = "AND NOT "; $subread = "AND NOT `mc`."; } else { $read = "AND "; $subread = "AND `mc`."; } $read2 = "`id` IN (SELECT `rel_object_id` FROM `" . TABLE_PREFIX . "read_objects` `t` WHERE `user_id` = " . logged_user()->getId() . " AND `t`.`rel_object_manager` = 'MailContents' AND `t`.`is_read` = '1')"; $read .= $read2; $subread .= $read2; } else { $read = ""; $subread = ""; } //Check for tags if (!isset($tag) || $tag == '' || $tag == null) { $tagstr = ""; // dummy condition $subtagstr = ""; } else { $tagstr = "AND (SELECT count(*) FROM `" . TABLE_PREFIX . "tags` WHERE `" . TABLE_PREFIX . "mail_contents`.`id` = `" . TABLE_PREFIX . "tags`.`rel_object_id` AND `" . TABLE_PREFIX . "tags`.`tag` = " . DB::escape($tag) . " AND `" . TABLE_PREFIX . "tags`.`rel_object_manager` ='MailContents' ) > 0 "; $subtagstr = "AND (SELECT count(*) FROM `" . TABLE_PREFIX . "tags` WHERE " . "`mc`.`id` = `" . TABLE_PREFIX . "tags`.`rel_object_id` AND `" . TABLE_PREFIX . "tags`.`tag` = " . DB::escape($tag) . " AND `" . TABLE_PREFIX . "tags`.`rel_object_manager` ='MailContents' ) > 0 "; } $permissions = ' AND ( ' . permissions_sql_for_listings(MailContents::instance(), ACCESS_LEVEL_READ, logged_user(), $project instanceof Project ? $project->getId() : 0) . ')'; //Check for projects (uses accountConditions if ($project instanceof Project) { $pids = $project->getAllSubWorkspacesQuery(!$archived); $projectConditions = " AND " . self::getWorkspaceString($pids); } else { $projectConditions = ""; } if ($archived) { $archived_cond = "AND `archived_by_id` <> 0"; } else { $archived_cond = "AND `archived_by_id` = 0"; } $state_conv_cond_1 = $state != 'received' ? " {$stateConditions} AND " : " `state` <> '2' AND "; $state_conv_cond_2 = $state != 'received' ? " AND (`mc`.`state` = '1' OR `mc`.`state` = '3' OR `mc`.`state` = '5') " : " AND `mc`.`state` <> '2' "; if (user_config_option('show_emails_as_conversations')) { $archived_by_id = $archived ? "AND `mc`.`archived_by_id` != 0" : "AND `mc`.`archived_by_id` = 0"; $trashed_by_id = "AND `mc`.`trashed_on` = " . DB::escape(EMPTY_DATETIME); $conversation_cond = "AND IF(`conversation_id` = 0, {$stateConditions}, {$state_conv_cond_1} NOT EXISTS (SELECT * FROM `" . TABLE_PREFIX . "mail_contents` `mc` WHERE `" . TABLE_PREFIX . "mail_contents`.`conversation_id` = `mc`.`conversation_id` AND `" . TABLE_PREFIX . "mail_contents`.`account_id` = `mc`.`account_id` AND `" . TABLE_PREFIX . "mail_contents`.`received_date` < `mc`.`received_date` {$archived_by_id} AND `mc`.`is_deleted` = 0 {$trashed_by_id} {$subtagstr} {$subread} {$state_conv_cond_2}))"; $box_cond = "AND IF(EXISTS(SELECT * FROM `" . TABLE_PREFIX . "mail_contents` `mc` WHERE `" . TABLE_PREFIX . "mail_contents`.`conversation_id` = `mc`.`conversation_id` AND `" . TABLE_PREFIX . "mail_contents`.`id` <> `mc`.`id` AND `" . TABLE_PREFIX . "mail_contents`.`account_id` = `mc`.`account_id` {$archived_by_id} AND `mc`.`is_deleted` = 0 {$trashed_by_id} AND {$stateConditions}), TRUE, {$stateConditions})"; } else { $conversation_cond = ""; $box_cond = "AND {$stateConditions}"; } $conditions = "`is_deleted` = 0 {$archived_cond} {$projectConditions} {$accountConditions} {$tagstr} {$classified} {$read} {$permissions} {$conversation_cond} {$box_cond}"; if ($count) { return self::count($conditions); } else { if (!defined('EMAIL_PERFORMANCE_WORKAROUND') || !EMAIL_PERFORMANCE_WORKAROUND) { return self::paginate(array('conditions' => $conditions, 'order' => "{$order_by} {$dir}"), config_option('files_per_page'), $start / $limit + 1); } else { /* COMPLEX WORKAROUND FOR PERFORMANCE */ $conditions = "`is_deleted` = 0 {$archived_cond} {$projectConditions} {$tagstr} {$classified} {$read} {$accountConditions}"; $page = (int) ($start / $limit) + 1; $order = "{$order_by} {$dir}"; $count = null; if (defined('INFINITE_PAGING') && INFINITE_PAGING) { $count = 10000000; } $pagination = new DataPagination($count ? $count : self::count($conditions), $limit, $page); $ids = self::findAll(array('conditions' => $conditions, 'id' => true)); $ids = array_reverse($ids); $ret_ids = array(); $offset = 0; $block_len = $pagination->getItemsPerPage(); while (count($ret_ids) < $pagination->getLimitStart() + $pagination->getItemsPerPage() && $offset < count($ids)) { $tmp_ids = array(); for ($i = $offset; $i < count($ids) && $i < $offset + $block_len; $i++) { $tmp_ids[] = $ids[$i]; } $tmp_ids = self::findAll(array('conditions' => "`id` IN (" . implode(",", $tmp_ids) . ") {$permissions} {$conversation_cond} {$box_cond}", 'order' => $order, 'id' => true)); $ret_ids = array_merge($ret_ids, $tmp_ids); $offset += $block_len; } $ids = array(); for ($i = $pagination->getLimitStart(); $i < count($ret_ids); $i++) { $ids[] = $ret_ids[$i]; } $objects = array(); foreach ($ids as $id) { $objects[] = self::findById($id); } return array($objects, $pagination); } } }
<?php $genid = gen_id(); $selectedPage = user_config_option('custom_report_tab'); $customReports = Reports::getAllReportsByObjectType(); $report = new Report(); $can_add_reports = $report->canAdd(logged_user(), active_context()); $reportPages = array(); $object_types = ObjectTypes::getAvailableObjectTypes(); foreach ($object_types as $ot) { $reportPages[$ot->getId()] = array("name" => $ot->getName(), "display_name" => lang($ot->getName())); } $ignored = null; Hook::fire('modify_report_pages', $ignored, $reportPages); // To add, edit or remove report pages $default_reports = array('task' => array('task time report' => array('url' => get_url('reporting', 'total_task_times_p'), 'name' => lang('task time report'), 'description' => lang('task time report description')))); Hook::fire('modify_default_reports', $ignored, $default_reports); // To add, edit or remove default reports require_javascript("og/ReportingFunctions.js"); ?> <div style="padding:7px"> <table width=100% id="reportingMenu"> <tr> <td style="height:2px;width:140px"></td><td width=12></td><td style="line-height:2px;"> </td><td width=12></td> </tr> <tr> <td height=12></td> <td rowspan=<?php echo count($reportPages) + 2; ?>
$this->includeTemplate(get_template_path('widget', 'dashboard')); ?> </td></tr> <?php } ?> <tr><td colspan=2> <?php if (user_config_option('show calendar widget') && module_enabled('calendar')) { tpl_assign("widgetClass", 'dashCalendar'); tpl_assign("widgetTitle",lang('upcoming events milestones and tasks')); tpl_assign("widgetTemplate", 'calendar'); $this->includeTemplate(get_template_path('widget', 'dashboard')); } ?> </td></tr> <tr><td> <?php if (user_config_option('show activity widget')) { tpl_assign("widgetClass", 'dashActivity'); tpl_assign("widgetTitle", lang('activity')); tpl_assign("widgetTemplate", 'activity'); $this->includeTemplate(get_template_path('widget', 'dashboard')); } if (isset($tasks_in_progress) && $tasks_in_progress) { switch($assign_type) { case 0: $title = lang('tasks in progress'); break; case 1: $title = lang('my tasks in progress'); break; case 2: $title = lang('tasks in progress for', $assigned_to->getObjectName()); break; case 3: $title = lang('tasks in progress for', $assigned_to->getName()); break; } tpl_assign("widgetClass", 'dashTasksInProgress'); tpl_assign("widgetTitle",$title);
<?php } ?> </div> </div> <div class="adminSeparator"></div> <div class="adminMainBlock"> <div id="<?php echo $genid ?>add_user_advanced" style="display:none"> <fieldset> <legend><?php echo lang('advanced')?></legend> <div class="formBlock" onclick="og.showSelectTimezone('<?php echo $genid ?>')"> <?php echo label_tag(lang('timezone'), 'userFormTimezone', false)?> <span class="desc"><?php echo lang('auto detect user timezone') ?></span> <div id ="<?php echo $genid?>detectTimeZone"> <?php echo yes_no_widget('user[autodetect_time_zone]', 'userFormAutoDetectTimezone', user_config_option('autodetect_time_zone', null, $user->getId()), lang('yes'), lang('no')) ?> <div id="<?php echo $genid?>selecttzdiv" <?php if (user_config_option('autodetect_time_zone', null, $user->getId())) echo 'style="display:none"'; ?>> <?php echo select_timezone_widget('user[timezone]', array_var($user_data, 'timezone'), array('id' => 'userFormTimezone', 'class' => 'long', 'tabindex' => '600')) ?> </div> </div> <script type="text/javascript"> og.addUserTypeChange('<?php echo $genid?>',$(':input[name$="user[type]"]').val()); og.showSelectTimezone = function(genid) { check = document.getElementById("userFormAutoDetectTimezoneYes"); div = document.getElementById(genid + "selecttzdiv"); if (check.checked == true){ div.style.display= "none"; }else{ div.style.display= ""; } };
function get_member_custom_property_value_for_listing($cp, $member_id, $cp_vals = null) { if (is_null($cp_vals)) { $cp_vals = MemberCustomPropertyValues::getMemberCustomPropertyValues($member_id, $cp->getId()); } $val_to_show = ""; foreach ($cp_vals as $cp_val) { if (in_array($cp->getType(), array('contact', 'user')) && $cp_val instanceof MemberCustomPropertyValue) { $cp_contact = Contacts::findById($cp_val->getValue()); if ($cp_contact instanceof Contact) { $cp_val->setValue($cp_contact->getObjectName()); } else { $cp_val->setValue(""); } } if ($cp->getType() == 'date' && $cp_val instanceof MemberCustomPropertyValue) { $format = user_config_option('date_format'); Hook::fire("custom_property_date_format", null, $format); $tmp_date = DateTimeValueLib::dateFromFormatAndString(DATE_MYSQL, $cp_val->getValue()); if (str_starts_with($cp_val->getValue(), EMPTY_DATE)) { $formatted = ""; } else { if (str_ends_with($cp_val->getValue(), "00:00:00")) { $formatted = $tmp_date->format(user_config_option('date_format')); } else { $formatted = $tmp_date->format($format); } } $cp_val->setValue($formatted); } if ($cp->getType() == 'address' && $cp_val instanceof MemberCustomPropertyValue) { $values = str_replace("\\|", "%%_PIPE_%%", $cp_val->getValue()); $exploded = explode("|", $values); foreach ($exploded as &$v) { $v = str_replace("%%_PIPE_%%", "|", $v); $v = str_replace("'", "\\'", $v); } if (count($exploded) > 0) { $address_type = array_var($exploded, 0, ''); $street = array_var($exploded, 1, ''); $city = array_var($exploded, 2, ''); $state = array_var($exploded, 3, ''); $country = array_var($exploded, 4, ''); $zip_code = array_var($exploded, 5, ''); $country_name = CountryCodes::getCountryNameByCode($country); $tmp = array(); if ($street != '') { $tmp[] = $street; } if ($city != '') { $tmp[] = $city; } if ($state != '') { $tmp[] = $state; } if ($zip_code != '') { $tmp[] = $zip_code; } if ($country_name != '') { $tmp[] = $country_name; } $cp_val->setValue(implode(' - ', $tmp)); } } $val_to_show .= ($val_to_show == "" ? "" : ", ") . ($cp_val instanceof MemberCustomPropertyValue ? $cp_val->getValue() : ""); } $val_to_show = html_to_text($val_to_show); return $val_to_show; }
<?php require_javascript('og/modules/addMessageForm.js'); $genid = gen_id(); $object = $message; $visible_cps = CustomProperties::countVisibleCustomPropertiesByObjectType($message->getObjectTypeId()); $loc = user_config_option('localization'); if (strlen($loc) > 2) $loc = substr($loc, 0, 2); ?> <form onsubmit="return og.setDescription();" class="add-message" id="<?php echo $genid ?>submit-edit-form" style='height:100%;background-color:white' action="<?php echo $message->isNew() ? get_url('message', 'add') : $message->getEditUrl() ?>" method="post" enctype="multipart/form-data" > <div class="message"> <div class="coInputHeader"> <div class="coInputHeaderUpperRow"> <div class="coInputTitle"> <table style="width:535px"><tr><td> <?php echo $message->isNew() ? lang('new message') : lang('edit message') ?> </td><td style="text-align:right"> <?php echo submit_button($message->isNew() ? lang('add message') : lang('save changes'),'s',array('style'=>'margin-top:0px;margin-left:10px', 'tabindex' => '5')) ?> </td></tr></table> </div> </div> <div> <?php $is_required = true; if(config_option('untitled_notes')) { $is_required = false; } echo label_tag(lang('title'), $genid . 'messageFormTitle', $is_required) ?>
<input type="hidden" id="hfCompanies" value="<?php echo clean(str_replace('"',"'", str_replace("'", "\'", json_encode($companies_array)))) ?>"/> <input type="hidden" id="hfUserPreferences" value="<?php echo clean(str_replace('"',"'", str_replace("'", "\'", json_encode($userPreferences)))) ?>"/> <input type="hidden" id="hfObjectSubtypes" value="<?php echo clean(str_replace('"',"'", str_replace("'", "\'", json_encode($object_subtypes_array)))) ?>"/> <input type="hidden" id="hfDependencyCount" value="<?php echo clean(str_replace('"',"'", str_replace("'", "\'", json_encode($dependency_count)))) ?>"/> <input id="<?php echo $genid?>type_related" type="hidden" name="type_related" value="only" /> <input id="<?php echo $genid?>complete_task" type="hidden" name="complete_task" value="yes" /> </div> <div id="tasksPanel" class="ogContentPanel" style="background-color:white;background-color:#F0F0F0;height:100%;width:100%;"> <div id="tasksPanelTopToolbar" class="x-panel-tbar" style="width:100%;height:30px;display:block;background-color:#F0F0F0;"></div> <div id="tasksPanelBottomToolbar" class="x-panel-tbar" style="width:100%;height:30px;display:block;background-color:#F0F0F0;border-bottom:1px solid #CCC;"></div> <div id="tasksPanelContent" style="background-color:white;padding:7px;padding-top:0px;overflow-y:scroll;position:relative;"> <?php if (isset($displayTooManyTasks) && $displayTooManyTasks){ ?> <div class="tasksPanelWarning ico-warning32" style="font-size:10px;color:#666;background-repeat:no-repeat;padding-left:40px;max-width:920px; margin:20px;border:1px solid #E3AD00;background-color:#FFF690;background-position:4px 4px;"> <div style="font-weight:bold;width:99%;text-align:center;padding:4px;color:#AF8300;"><?php echo lang('too many tasks to display', user_config_option('task_display_limit')) ?></div> </div> <?php } ?> <div id="tasksPanelContainer" style="background-color:white;padding:7px;padding-top:0px;"> <?php if(!(isset($tasks) || $userPreferences['groupBy'] == 'milestone')) { ?> <div style="font-size:130%;width:100%;text-align:center;padding-top:10px;color:#777;"><?php echo lang('no tasks to display') ?></div> <?php } ?> </div> </div> </div> <script type="text/javascript"> if (!ogTasks.tasks_object_type_id) ogTasks.tasks_object_type_id = '<?php echo ProjectTasks::instance()->getObjectTypeId() ?>'; if (rx__TasksDrag) rx__TasksDrag.initialize();
/** * Returns a DateTimeValue from a date representation from pick_date_widget2 * * @param string $value * @param DateTimeValue $default * @return DateTimeValue */ function getDateValue($value = '', $default = EMPTY_DATETIME) { if ($value instanceof DateTimeValue) { return $value; } if ($value != '') { $date_format = user_config_option('date_format'); return DateTimeValueLib::dateFromFormatAndString($date_format, $value); } return $default; }