//if } // if $otherInvitationsTable = ''; if (!$event->isNew()) { $otherInvitations = EventInvitations::findAll(array('conditions' => 'event_id = ' . $event->getId())); if (isset($otherInvitations) && is_array($otherInvitations)) { $otherInvitationsTable .= '<div class="coInputMainBlock adminMainBlock" style="width:70%;">'; $otherInvitationsTable .= '<table style="width:100%;"><col width="50%" /><col width="50%" />'; $otherInvitationsTable .= '<tr><th><b>' . lang('name') . '</b></th><th><b>' . lang('participate') . '</b></th></tr>'; $isAlt = false; $cant = 0; foreach ($otherInvitations as $inv) { $inv_user = Contacts::findById($inv->getContactId()); if ($inv_user instanceof Contact) { if (can_access($inv_user, $event->getMembers(), ProjectEvents::instance()->getObjectTypeId(), ACCESS_LEVEL_READ)) { if (!SystemPermissions::userHasSystemPermission(logged_user(), 'can_update_other_users_invitations')) { // only show status $state_desc = lang('pending response'); if ($inv->getInvitationState() == 1) { $state_desc = lang('yes'); } else { if ($inv->getInvitationState() == 2) { $state_desc = lang('no'); } else { if ($inv->getInvitationState() == 3) { $state_desc = lang('maybe'); } } } $otherInvitationsTable .= '<tr' . ($isAlt ? ' class="altRow"' : '') . '><td>' . clean($inv_user->getObjectName()) . '</td><td>' . $state_desc . '</td></tr>';
/** * Return manager instance * * @access protected * @param void * @return ProjectEvents */ function manager() { if (!$this->manager instanceof ProjectEvents) { $this->manager = ProjectEvents::instance(); } return $this->manager; }
echo date("G", mktime(($hour + 1) / 2)); ?> , <?php echo ($hour + 1) % 2 == 0 ? 0 : 30; ?> , <?php echo $use_24_hours ? 'true' : 'false'; ?> ,'<?php echo $date->format($date_format); ?> ', '<?php echo $genid; ?> ', '<?php echo ProjectEvents::instance()->getObjectTypeId(); ?> ');"> <?php } else { echo ">"; } ?> </div> <script> og.ev_cell_dates[<?php echo $day_of_week; ?> ] = {day:<?php echo $date->getDay();
/** * Returns all events for the given range, tag and considers the active project * * @param DateTimeValue $date * @param String $tags * @return unknown */ static function getRangeProjectEvents(DateTimeValue $start_date, DateTimeValue $end_date, $tags = '', $project = null, $archived = false) { $start_year = date("Y", mktime(0, 0, 1, $start_date->getMonth(), $start_date->getDay(), $start_date->getYear())); $start_month = date("m", mktime(0, 0, 1, $start_date->getMonth(), $start_date->getDay(), $start_date->getYear())); $start_day = date("d", mktime(0, 0, 1, $start_date->getMonth(), $start_date->getDay(), $start_date->getYear())); $end_year = date("Y", mktime(0, 0, 1, $end_date->getMonth(), $end_date->getDay(), $end_date->getYear())); $end_month = date("m", mktime(0, 0, 1, $end_date->getMonth(), $end_date->getDay(), $end_date->getYear())); $end_day = date("d", mktime(0, 0, 1, $end_date->getMonth(), $end_date->getDay(), $end_date->getYear())); if (!is_numeric($start_day) or !is_numeric($start_month) or !is_numeric($start_year) or !is_numeric($end_day) or !is_numeric($end_month) or !is_numeric($end_year)) { return NULL; } //permission check $permissions = ' AND ( ' . permissions_sql_for_listings(ProjectEvents::instance(), ACCESS_LEVEL_READ, logged_user()) . ')'; if ($project instanceof Project) { $pids = $project->getAllSubWorkspacesQuery(!$archived); $wsstring = " AND " . self::getWorkspaceString($pids); } else { $wsstring = ""; } if (isset($tags) && $tags && $tags != '') { $tag_str = " AND EXISTS (SELECT * FROM `" . TABLE_PREFIX . "tags` `t` WHERE `tag` IN (" . DB::escape($tags) . ") AND `" . TABLE_PREFIX . "project_events`.`id` = `t`.`rel_object_id` AND `t`.`rel_object_manager` = 'ProjectEvents') "; } else { $tag_str = ""; } $invited = " AND `id` IN (SELECT `event_id` FROM `" . TABLE_PREFIX . "event_invitations` WHERE `user_id` = " . logged_user()->getId() . ")"; if ($archived) { $archived_cond = " AND `archived_by_id` <> 0"; } else { $archived_cond = " AND `archived_by_id` = 0"; } $tz_hm = "'" . floor(logged_user()->getTimezone()) . ":" . abs(logged_user()->getTimezone()) % 1 * 60 . "'"; $s_date = new DateTimeValue($start_date->getTimestamp() - logged_user()->getTimezone() * 3600); $e_date = new DateTimeValue($end_date->getTimestamp() - logged_user()->getTimezone() * 3600); $e_date->add("d", 1); $start_date_str = $s_date->format("Y-m-d H:i:s"); $end_date_str = $e_date->format("Y-m-d H:i:s"); $first_d = $start_day; while ($first_d > 7) { $first_d -= 7; } $week_of_first_day = date("W", mktime(0, 0, 0, $start_month, $first_d, $start_year)); $conditions = "\t((\n\t\t\t\t-- \n\t\t\t\t-- THIS RETURNS EVENTS ON THE ACTUAL DAY IT'S SET FOR (ONE TIME EVENTS)\n\t\t\t\t-- \n\t\t\t\t(\n\t\t\t\t\t`repeat_h` = 0 \n\t\t\t\t\tAND `duration` >= '{$start_date_str}' \n\t\t\t\t\tAND `start` < '{$end_date_str}' \n\t\t\t\t) \n\t\t\t\t-- \n\t\t\t\t-- THIS RETURNS REGULAR REPEATING EVENTS - DAILY, WEEKLY, MONTHLY, OR YEARLY.\n\t\t\t\t-- \n\t\t\t\tOR \n\t\t\t\t(\n\t\t\t\t\t`repeat_h` = 0 \n\t\t\t\t\tAND\n\t\t\t\t\tDATE(`start`) < '{$end_date_str}'\n\t\t\t\t\tAND\n\t\t\t\t\t(\t\t\t\t\t\t\t\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tDATE_ADD(`start`, INTERVAL (`repeat_num`-1)*`repeat_d` DAY) >= '{$start_date_str}' \n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_forever = 1\n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_end >= '{$start_year}-{$start_month}-{$start_day}'\n\t\t\t\t\t\t)\n\t\t\t\t\t\tOR\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tDATE_ADD(`start`, INTERVAL (`repeat_num`-1)*`repeat_m` MONTH) >= '{$start_date_str}' \n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_forever = 1\n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_end >= '{$start_year}-{$start_month}-{$start_day}'\n\t\t\t\t\t\t)\n\t\t\t\t\t\tOR\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tDATE_ADD(`start`, INTERVAL (`repeat_num`-1)*`repeat_y` YEAR) >= '{$start_date_str}' \n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_forever = 1\n\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\trepeat_end >= '{$start_year}-{$start_month}-{$start_day}'\n\t\t\t\t\t\t)\n\t\t\t\t\t)\t\t\n\t\t\t\t)\n\t\t\t\t-- \n\t\t\t\t-- THIS RETURNS EVENTS SET TO BE A CERTAIN DAY OF THE WEEK IN A CERTAIN WEEK EVERY CERTAIN AMOUNT OF MONTHS\n\t\t\t\t-- \n\t\t\t\tOR\n\t\t\t\t(\n\t\t\t\t\tDATE(`start`) <= '{$start_date_str}'\n\t\t\t\t\tAND\n\t\t\t\t\t`repeat_h` = 1 \n\t\t\t\t\tAND\n\t\t\t\t\t`repeat_dow` = DAYOFWEEK('{$start_date_str}') \n\t\t\t\t\tAND\n\t\t\t\t\t`repeat_wnum` + {$week_of_first_day} - 1 = WEEK('{$start_date_str}', 3) \n\t\t\t\t\tAND\n\t\t\t\t\tMOD( PERIOD_DIFF(DATE_FORMAT(`start`, '%Y%m'), DATE_FORMAT('{$start_date_str}', '%Y%m')), `repeat_mjump`) = 0\n\t\t\t\t)\t\t\t\t\n\t\t\t)\n\t\t\t{$wsstring}\n\t\t\t{$permissions} {$invited}\n\t\t\t{$tag_str} {$archived_cond} )"; $result_events = self::findAll(array('conditions' => $conditions, 'order' => '`start`')); // Find invitations for events and logged user ProjectEvents::addInvitations($result_events); return $result_events; }
/** * Send event notification to the list of users ($people) * * @param ProjectEvent $event Event * @param array $people * @return boolean * @throws NotifierConnectionError */ static function notifEvent(ProjectEvent $object, $people, $notification, $sender) { if (!is_array($people) || !count($people) || !$sender instanceof Contact) { return; // nothing here... } // if $name = $object->getObjectName(); $type = $object->getObjectTypeName(); $typename = lang($object->getObjectTypeName()); tpl_assign('object', $object); tpl_assign('title', $name); tpl_assign('description', escape_html_whitespace(convert_to_links(clean($object->getDescription())))); //descripction //context $contexts = array(); $members = $object->getMembers(); if (count($members) > 0) { foreach ($members as $member) { $dim = $member->getDimension(); if ($dim->getIsManageable()) { if ($dim->getCode() == "customer_project" || $dim->getCode() == "customers") { $obj_type = ObjectTypes::findById($member->getObjectTypeId()); if ($obj_type instanceof ObjectType) { $contexts[$dim->getCode()][$obj_type->getName()][] = '<span style="' . get_workspace_css_properties($member->getMemberColor()) . '">' . $member->getName() . '</span>'; } } else { $contexts[$dim->getCode()][] = '<span style="' . get_workspace_css_properties($member->getMemberColor()) . '">' . $member->getName() . '</span>'; } } } } tpl_assign('contexts', $contexts); //folders $attachments = array(); try { $content = FileRepository::getBackend()->getFileContent(owner_company()->getPictureFile()); if ($content) { $file_path = ROOT . "/tmp/logo_empresa.png"; $handle = fopen($file_path, 'wb'); if ($handle) { fwrite($handle, $content); fclose($handle); $attachments['logo'] = array('cid' => gen_id() . substr($sender->getEmailAddress(), strpos($sender->getEmailAddress(), '@')), 'path' => $file_path, 'type' => 'image/png', 'disposition' => 'inline', 'name' => 'logo_empresa.png'); } } } catch (FileNotInRepositoryError $e) { unset($attachments['logo']); } tpl_assign('attachments', $attachments); // attachments //invitations $invitations = EventInvitations::findAll(array('conditions' => 'event_id = ' . $object->getId())); if (isset($invitations) && is_array($invitations)) { $guests = ""; $send_link = array(); foreach ($invitations as $inv) { $inv_user = Contacts::findById($inv->getContactId()); if ($inv_user instanceof Contact) { if (can_access($inv_user, $object->getMembers(), ProjectEvents::instance()->getObjectTypeId(), ACCESS_LEVEL_READ)) { $state_desc = lang('pending response'); if ($inv->getInvitationState() == 1) { $state_desc = lang('yes'); } else { if ($inv->getInvitationState() == 2) { $state_desc = lang('no'); } else { if ($inv->getInvitationState() == 3) { $state_desc = lang('maybe'); } } } $guests .= '<div style="line-height: 20px; clear:both;">'; $guests .= '<div style="width: 35%;line-height: 20px; float: left;">' . clean($inv_user->getObjectName()) . '</div>'; $guests .= '<div style="line-height: 20px; float: left;">' . $state_desc . '</div></div>'; } if ($inv->getInvitationState() == 0) { $send_link[] = $inv_user->getId(); } } } } tpl_assign('guests', $guests); // invitations $emails = array(); foreach ($people as $user) { if ($user->getId() != $sender->getId() && !$user->getDisabled()) { // send notification on user's locale and with user info $locale = $user->getLocale(); Localization::instance()->loadSettings($locale, ROOT . '/language'); //ALL SUBSCRIBERS if ($object->getSubscribers()) { $subscribers = $object->getSubscribers(); $string_subscriber = ''; $total_s = count($subscribers); $c = 0; foreach ($subscribers as $subscriber) { $c++; if ($c == $total_s && $total_s > 1) { $string_subscriber .= lang('and'); } else { if ($c > 1) { $string_subscriber .= ", "; } } $string_subscriber .= $subscriber->getFirstName(); if ($subscriber->getSurname() != "") { $string_subscriber .= " " . $subscriber->getSurname(); } } tpl_assign('subscribers', $string_subscriber); // subscribers } //start if ($object->getStart() instanceof DateTimeValue) { $date = Localization::instance()->formatDescriptiveDate($object->getStart(), $user->getTimezone()); $time = Localization::instance()->formatTime($object->getStart(), $user->getTimezone()); tpl_assign('start', $date); //start if ($object->getTypeId() != 2) { tpl_assign('time', $time); //time } } if ($object->getTypeId() != 2) { //duration if ($object->getDuration() instanceof DateTimeValue) { $durtime = $object->getDuration()->getTimestamp() - $object->getStart()->getTimestamp(); $durhr = $durtime / 3600 % 24; //seconds per hour tpl_assign('duration', $durhr . " hs"); //duration } } else { tpl_assign('duration', lang('all day event')); //duration } $links = array(); if (in_array($user->getId(), $send_link)) { $links = array(array('img' => get_image_url("/16x16/complete.png"), 'text' => lang('accept invitation'), 'url' => get_url('event', 'change_invitation_state', array('at' => 1, 'e' => $object->getId(), 'u' => $user->getId()))), array('img' => get_image_url("/16x16/del.png"), 'text' => lang('reject invitation'), 'url' => get_url('event', 'change_invitation_state', array('at' => 2, 'e' => $object->getId(), 'u' => $user->getId())))); $description_title = lang("new notification event invitation", $object->getObjectName(), $sender->getObjectName()); $subject_mail = lang("new notification event", $name, $sender->getObjectName()); } else { $description_title = lang("{$notification} notification event desc", $object->getObjectName(), $sender->getObjectName()); $subject_mail = lang("{$notification} notification {$type}", $name, $typename); } tpl_assign('links', $links); tpl_assign('description_title', $description_title); //description_title $toemail = $user->getEmailAddress(); if (!$toemail) { continue; } $emails[] = array("to" => array(self::prepareEmailAddress($toemail, $user->getObjectName())), "from" => self::prepareEmailAddress($sender->getEmailAddress(), $sender->getObjectName()), "subject" => $subject = $subject_mail, "body" => tpl_fetch(get_template_path('general', 'notifier')), "attachments" => $attachments); } } // foreach $locale = logged_user() instanceof Contact ? logged_user()->getLocale() : DEFAULT_LOCALIZATION; Localization::instance()->loadSettings($locale, ROOT . '/language'); self::queueEmails($emails); }
</div> </form> <?php }?> <div style="clear: both;"></div> <div style="padding-top:5px;text-align:left;"> <a href="#" class="option" onclick="og.toggleAndBolden('<?php echo $genid ?>add_mail_select_context_div',this)"><?php echo lang('context') ?></a> </div> </div> <div id="<?php echo $genid ?>add_mail_select_context_div" style="display:none" > <fieldset> <legend><?php echo lang('context') ?></legend> <?php if (array_var($user, 'id')) { render_member_selectors(ProjectEvents::instance()->getObjectTypeId(), $genid, array_var($user, 'related_to'), array('listeners' => $listeners)); } else { render_member_selectors(ProjectEvents::instance()->getObjectTypeId(), $genid, null, array('select_current_context' => true, 'listeners' => $listeners)); } ?> </fieldset> </div> <?php if(isset($user) && is_array($user) && count($user)) { ?> <div class="adminMainBlock"> <?php if(isset($calendars) && is_array($calendars) && count($calendars)) { ?> <table class="adminListing" style="min-width: 400px; margin-top: 10px;"> <tr> <th width="90%"><?php echo lang('name calendar') ?></th> <th><?php echo lang('options') ?></th> </tr> <?php $isAlt = true; foreach($calendars as $calendar) {
function canAdd(Contact $user, $context, &$notAllowedMember = '') { return can_add($user, $context, ProjectEvents::instance()->getObjectTypeId(), $notAllowedMember); }
/** * Return manager instance * * @access protected * @param void * @return ProjectEvents */ function manager() { if(!($this->manager instanceof ProjectEvents)) $this->manager = ProjectEvents::instance(); return $this->manager; } // manager
og.EventPopUp.show(null, {day: day, month: month, year: year, hour: 9, minute: 0, durationhour: 1, durationmin: 0, start_value: st_val, start_time: '9:00', type_id:2, view:'month', title: lang('add event'), time_format: '<?php echo $timeformat ?>', hide_calendar_toolbar: 1, genid: genid, otype: <?php echo ProjectEvents::instance()->getObjectTypeId(); ?> }, ''); } if (Ext.isIE) document.getElementById('ie_scrollbar_adjust').style.display = 'block'; function resizeGridContainer(e, id) { maindiv = document.getElementById('cal_main_div'); if (maindiv == null) { og.removeDomEventHandler(window, 'resize', id); } else { var tbarsh = Ext.get('calendarPanelSecondTopToolbar').getHeight() + Ext.get('calendarPanelTopToolbar').getHeight(); var cmt = document.getElementById('calendarMonthTitle'); var mainHeight = maindiv.offsetHeight; var divHeight = maindiv.offsetHeight - tbarsh - cmt.offsetHeight;
$date = $dates[$day_of_week]; $left = (100/7)*$day_of_week; for ($hour=0; $hour<=47; $hour++){ $top = (PX_HEIGHT/2) * $hour; $div_id = 'h' . $day_of_week . "_" . $hour; ?> <div id="<?php echo $div_id?>" style="left:<?php echo $left ?>%;width:<?php echo $width_percent ?>%;top:<?php echo $top?>px;height:21px;position:absolute;z-index: 90;<?php echo $today_style[$day_of_week]?>" <?php if (!logged_user()->isGuest()) { ?> onmouseover="if (!og.selectingCells) og.overCell('<?php echo $div_id?>'); else og.paintSelectedCells('<?php echo $div_id?>');" onmouseout="if (!og.selectingCells) og.resetCell('<?php echo $div_id?>');" onmousedown="og.selectStartDateTime(<?php echo $date->getDay() ?>, <?php echo $date->getMonth()?>, <?php echo $date->getYear()?>, <?php echo date("G",mktime($hour/2))?>, <?php echo ($hour % 2 == 0) ? 0 : 30 ?>); og.resetCell('<?php echo $div_id?>'); og.paintingDay = <?php echo $day_of_week ?>; og.paintSelectedCells('<?php echo $div_id?>');" onmouseup="og.showEventPopup(<?php echo $date->getDay() ?>, <?php echo $date->getMonth()?>, <?php echo $date->getYear()?>, <?php echo date("G",mktime(($hour+1)/2))?>, <?php echo (($hour+1) % 2 == 0) ? 0 : 30 ?>, <?php echo ($use_24_hours ? 'true' : 'false'); ?>,'<?php echo $date->format($date_format) ?>', '<?php echo $genid?>', '<?php echo ProjectEvents::instance()->getObjectTypeId()?>');"> <?php } else echo ">"; ?> </div> <script> og.ev_cell_dates[<?php echo $day_of_week?>] = {day:<?php echo $date->getDay() ?>, month:<?php echo $date->getMonth()?>, year:<?php echo $date->getYear()?>} var ev_dropzone = new Ext.dd.DropZone('<?php echo $div_id?>', {ddGroup:'ev_dropzone'}); </script> <?php } ?> <div id="vd<?php echo $day_of_week ?>" style="left: <?php echo $left ?>%; height: <?php echo (PX_HEIGHT)*24 ?>px;border-left:3px double #DDDDDD !important; position:absolute;width:3px;z-index:110;"></div> <?php $cells = array(); for ($i = 0; $i < 24; $i++) { $cells[$i][0] = 0;
/** * This function will return paginated result. Result is an array where first element is * array of returned object and second populated pagination object that can be used for * obtaining and rendering pagination data using various helpers. * * Items and pagination array vars are indexed with 0 for items and 1 for pagination * because you can't use associative indexing with list() construct * * @access public * @param array $arguments Query argumens (@see find()) Limit and offset are ignored! * @param integer $items_per_page Number of items per page * @param integer $current_page Current page number * @return array */ function paginate($arguments = null, $items_per_page = 10, $current_page = 1) { if (isset($this) && instance_of($this, 'ProjectEvents')) { return parent::paginate($arguments, $items_per_page, $current_page); } else { return ProjectEvents::instance()->paginate($arguments, $items_per_page, $current_page); //$instance =& ProjectEvents::instance(); //return $instance->paginate($arguments, $items_per_page, $current_page); } // if }
function get_rendered_member_selectors() { $members = array(); $objectId = 0; if (array_var($_GET, 'id')) { $objectId = array_var($_GET, 'id'); $user = ExternalCalendarUsers::findByContactId(); $calendar = ExternalCalendars::findOne(array('conditions' => array("original_calendar_id=? AND ext_cal_user_id=?", $objectId, $user->getId()))); $object_type_id = ProjectEvents::instance()->getObjectTypeId(); $members_ids = explode(",", $calendar->getRelatedTo()); foreach ($members_ids as $members_id) { $members[] = $members_id; } } $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(); if (count($members) > 0) { render_member_selectors(ProjectEvents::instance()->getObjectTypeId(), $genid, $members, array('listeners' => $listeners), null, null, false); } else { render_member_selectors(ProjectEvents::instance()->getObjectTypeId(), $genid, null, array('select_current_context' => true, 'listeners' => $listeners), null, 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)); }
/** * 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; }
function format_value_to_print($col, $value, $type, $obj_type_id, $textWrapper = '', $dateformat = 'Y-m-d') { switch ($type) { case DATA_TYPE_STRING: if (preg_match(EMAIL_FORMAT, strip_tags($value))) { $formatted = strip_tags($value); } else { if ($col == 'is_user') { $formatted = $value == 1 ? lang('yes') : lang('no'); } else { if (strpos($value, "�") !== false) { $value = preg_replace('/\\xA0/s', ' ', $value); } $value = utf8_safe($value); $formatted = $textWrapper . $value . $textWrapper; } } break; case DATA_TYPE_INTEGER: if ($col == 'priority') { switch ($value) { case 100: $formatted = lang('low priority'); break; case 200: $formatted = lang('normal priority'); break; case 300: $formatted = lang('high priority'); break; case 400: $formatted = lang('urgent priority'); break; default: $formatted = clean($value); } } elseif ($col == 'time_estimate') { if ($value > 0) { $formatted = DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($value * 60), 'hm', 60); } else { $formatted = clean($value); } } else { $formatted = clean($value); } break; case DATA_TYPE_BOOLEAN: $formatted = $value == 1 ? lang('yes') : lang('no'); break; case DATA_TYPE_DATE: if ($value != 0) { if (str_ends_with($value, "00:00:00")) { $dateformat .= " H:i:s"; } try { $dtVal = DateTimeValueLib::dateFromFormatAndString($dateformat, $value); } catch (Exception $e) { $formatted = $value; } if (!isset($formatted)) { $formatted = format_date($dtVal, null, 0); } } else { $formatted = ''; } break; case DATA_TYPE_DATETIME: if ($value != 0) { try { $dtVal = DateTimeValueLib::dateFromFormatAndString("{$dateformat} H:i:s", $value); } catch (Exception $e) { $formatted = $value; } if ($dtVal instanceof DateTimeValue) { if ($obj_type_id == ProjectEvents::instance()->getObjectTypeId() || $obj_type_id == ProjectTasks::instance()->getObjectTypeId()) { $dtVal->advance(logged_user()->getTimezone() * 3600, true); } if ($obj_type_id == ProjectEvents::instance()->getObjectTypeId() && ($col == 'start' || $col == 'duration')) { $formatted = format_datetime($dtVal); } else { $formatted = format_date($dtVal, null, 0); } } } else { $formatted = ''; } break; default: $formatted = $value; } if ($formatted == '') { $formatted = '--'; } return $formatted; }
function allowed_users_view_events() { $comp_array = array(); $actual_user_id = isset($_GET['user']) ? $_GET['user'] : logged_user()->getId(); $evid = array_var($_GET, 'evid'); $i = 0; $companies_tmp = Contacts::findAll(array("conditions" => "is_company = 1")); $companies = array("0" => array('id' => $i++, 'name' => lang('without company'), 'logo_url' => '#')); foreach ($companies_tmp as $comptmp) { $companies[$comptmp->getId()] = array( 'id' => $i++, 'name' => $comptmp->getObjectName(), 'logo_url' => $comptmp->getPictureUrl() ); } $context_plain = array_var($_GET, 'context'); if (is_null($context_plain) || $context_plain == "") $context = active_context(); else $context = build_context_array($context_plain); $users = allowed_users_in_context(ProjectEvents::instance()->getObjectTypeId(), $context, ACCESS_LEVEL_READ); foreach ($companies as $id => $comp) { if (is_array($users) && count($users) > 0) { $comp_data = array( 'id' => $comp['id'], 'object_id' => $id, 'name' => $comp['name'], 'logo_url' => $comp['logo_url'], 'users' => array() ); foreach ($users as $user) { if ($user->getCompanyId() == $id) { $comp_data['users'][] = array( 'id' => $user->getId(), 'name' => $user->getObjectName(), 'avatar_url' => $user->getPictureUrl(), 'invited' => $evid == 0 ? ($user->getId() == $actual_user_id) : (EventInvitations::findOne(array('conditions' => "`event_id` = $evid and `contact_id` = ".$user->getId())) != null), 'mail' => $user->getEmailAddress() ); } } if (count($comp_data['users']) > 0) { $comp_array[] = $comp_data; } } } $object = array( "totalCount" => count($comp_array), "start" => 0, "companies" => $comp_array ); ajx_extra_data($object); ajx_current("empty"); }
function format_value_to_print($col, $value, $type, $obj_type_id, $textWrapper = '', $dateformat = 'Y-m-d') { switch ($type) { case DATA_TYPE_STRING: if (preg_match(EMAIL_FORMAT, strip_tags($value))) { $formatted = strip_tags($value); } else { $formatted = $textWrapper . clean($value) . $textWrapper; } break; case DATA_TYPE_INTEGER: if ($col == 'priority') { switch ($value) { case 100: $formatted = lang('low priority'); break; case 200: $formatted = lang('normal priority'); break; case 300: $formatted = lang('high priority'); break; case 400: $formatted = lang('urgent priority'); break; default: $formatted = clean($value); } } elseif ($col == 'time_estimate') { if ($value > 0) { $formatted = DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($value * 60), 'hm', 60); } else { $formatted = clean($value); } } else { $formatted = clean($value); } break; case DATA_TYPE_BOOLEAN: $formatted = $value == 1 ? lang('yes') : lang('no'); break; case DATA_TYPE_DATE: if ($value != 0) { if (str_ends_with($value, "00:00:00")) { $dateformat .= " H:i:s"; } $dtVal = DateTimeValueLib::dateFromFormatAndString($dateformat, $value); $formatted = format_date($dtVal, null, 0); } else { $formatted = ''; } break; case DATA_TYPE_DATETIME: if ($value != 0) { $dtVal = DateTimeValueLib::dateFromFormatAndString("{$dateformat} H:i:s", $value); if ($obj_type_id == ProjectEvents::instance()->getObjectTypeId() && $col == 'start') { $formatted = format_datetime($dtVal); } else { $formatted = format_date($dtVal, null, 0); } } else { $formatted = ''; } break; default: $formatted = $value; } if ($formatted == '') { $formatted = '--'; } return $formatted; }
/** * Empty implementation of abstract methods. Messages determine does user have * permissions to add comment * * @param void * @return null */ function canAdd(User $user, Project $project) { return can_add($user, $project, get_class(ProjectEvents::instance())); }