예제 #1
0
 /**
 * Return manager instance
 *
 * @access protected
 * @param void
 * @return ProjectEvents 
 */
 function manager() {
   if(!($this->manager instanceof ProjectEvents)) $this->manager = ProjectEvents::instance();
   return $this->manager;
 } // manager
 /**
  * Return manager instance
  *
  * @access protected
  * @param void
  * @return ProjectEvents 
  */
 function manager()
 {
     if (!$this->manager instanceof ProjectEvents) {
         $this->manager = ProjectEvents::instance();
     }
     return $this->manager;
 }
예제 #3
0
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;
}
예제 #4
0
            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();
 /**
  * Reaturn all calendar Events
  *
  * @param Project $project
  * @return array
  */
 static function getAllEventsByProject($project = null, $archived = false, $inc_sub = true, $user = null)
 {
     if ($project instanceof Project) {
         if ($inc_sub) {
             $pids = $project->getAllSubWorkspacesQuery(true);
         } else {
             $pids = $project->getId();
         }
         $wsstring = " AND " . self::getWorkspaceString($pids);
     } else {
         $wsstring = "";
     }
     if ($user instanceof User) {
         $permissions = " AND " . permissions_sql_for_listings(self::instance(), ACCESS_LEVEL_READ, $user);
     } else {
         $permissions = "";
     }
     if ($archived) {
         $archived_cond = " `archived_by_id` <> 0";
     } else {
         $archived_cond = " `archived_by_id` = 0";
     }
     $cond_str = $archived_cond . $wsstring . $permissions;
     $result_events = self::findAll(array('conditions' => array($cond_str)));
     // findAll
     // Find invitations for events and logged user
     ProjectEvents::addInvitations($result_events, $user instanceof User ? $user->getId() : 0);
     return $result_events;
 }
 function ical_export()
 {
     $this->setLayout('ical');
     require_once ROOT . '/environment/classes/event/CalFormatUtilities.php';
     if (!isset($_GET['t']) || !isset($_GET['cal'])) {
         header('HTTP/1.0 404 Not Found');
         die;
     }
     $token = $_GET['t'];
     $cal = $_GET['cal'];
     $inc_sub = isset($_GET['isw']) && $_GET['isw'] == 1;
     if (Users::tokenExists($token)) {
         $user = Users::getByToken($token);
         if ($cal == 0) {
             $project = null;
         } else {
             $project = Projects::findById($cal);
         }
         $events = ProjectEvents::getAllEventsByProject($project, false, $inc_sub, $user);
         $calendar_name = isset($_GET['n']) ? $_GET['n'] : $user->getDisplayName();
         tpl_assign('content', CalFormatUtilities::generateICalInfo($events, $calendar_name, $user));
     } else {
         header('HTTP/1.0 404 Not Found');
         die;
     }
 }
예제 #7
0
 //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 .= "&nbsp;";
 $output .= "</div>";
 // This loop writes the events for the day in the cell
 if (is_numeric($w)) {
     $result = ProjectEvents::getDayProjectEvents($dtv, $tags, active_project(), logged_user()->getId(), ' 0 1 3');
     if (!$result) {
         $result = array();
     }
     if ($milestones) {
         $result = array_merge($result, $milestones);
     }
     if ($tasks) {
         $result = array_merge($result, $tasks);
     }
     if ($birthdays) {
         $result = array_merge($result, $birthdays);
     }
     if (count($result) < 1) {
         $output .= "&nbsp;";
     } else {
예제 #8
0
     $w = $day_of_month - $lastday;
 }
 $day_tmp = isset($w) && is_numeric($w) ? $w : 0;
 $dates[$day_of_week] = new DateTimeValue(mktime(0, 0, 0, $month_aux, $day_tmp, $year_aux));
 $today_style[$day_of_week] = '';
 if ($currentyear == $dates[$day_of_week]->getYear() && $currentmonth == $dates[$day_of_week]->getMonth() && $currentday == $dates[$day_of_week]->getday()) {
     // Today
     $drawHourLine = true;
     $today_style[$day_of_week] = 'background-color:#FFFF88;opacity:0.4;filter: alpha(opacity = 40);z-index=0;';
 } else {
     if ($year == $year_aux && $month == $month_aux && $day == $day_of_month) {
         // Selected day
         $today_style[$day_of_week] = 'background-color:#E4EEEE;opacity:0.4;filter: alpha(opacity = 40);z-index=0;';
     }
 }
 $results[$day_of_week] = ProjectEvents::getDayProjectEvents($dates[$day_of_week], $tags, active_project(), $user_filter, $status_filter);
 if (!$results[$day_of_week]) {
     $results[$day_of_week] = array();
 }
 foreach ($results[$day_of_week] as $key => $event) {
     if ($event->getTypeId() > 1) {
         $alldayevents[$day_of_week][] = $event;
         unset($results[$day_of_week][$key]);
     }
 }
 if (is_array($milestones)) {
     foreach ($milestones as $milestone) {
         if ($dates[$day_of_week]->getTimestamp() == mktime(0, 0, 0, $milestone->getDueDate()->getMonth(), $milestone->getDueDate()->getDay(), $milestone->getDueDate()->getYear())) {
             $alldayevents[$day_of_week][] = $milestone;
         }
     }
예제 #9
0
									$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;
예제 #10
0
    $output .= "<tr>";
    if (!user_config_option("start_monday")) {
        $output .= "    <th width='12.5%' align='center'>" . lang('sunday short') . '</th>' . "\n";
    }
    $output .= '
	<th width="15%">' . lang('monday short') . '</th>
	<th width="15%">' . lang('tuesday short') . '</th>
	<th width="15%">' . lang('wednesday short') . '</th>
	<th width="15%">' . lang('thursday short') . '</th>
	<th width="15%">' . lang('friday short') . '</th>
	<th width="12.5%">' . lang('saturday short') . '</th>';
    if (user_config_option("start_monday")) {
        $output .= '<th width="12.5%">' . lang('sunday short') . '</th>';
    }
    $output .= '</tr>';
    $result = ProjectEvents::getRangeProjectEvents($date_start, $date_end, $user_filter instanceof Contact ? $user_filter->getId() : -1, ' 0 1 3');
    foreach ($result as $ev) {
        $result = array_merge($result, $ev->getRepetitiveInstances($date_start, $date_end));
    }
    if (!$result) {
        $result = array();
    }
    if (!empty($milestones)) {
        $result = array_merge($result, $milestones);
    }
    if (!empty($tasks)) {
        $result = array_merge($result, $tasks);
    }
    if (!empty($birthdays)) {
        $result = array_merge($result, $birthdays);
    }
예제 #11
0
		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;
 /**
  * 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 export_google_calendar_for_user($user)
 {
     $service = $this->connect_with_google_calendar($user);
     if ($user->getSync() == 1) {
         $calendar_feng = ExternalCalendars::findFengCalendarByExtCalUserIdValue($user->getId());
         //get events starting from past 2 weeks
         $previous_week = strtotime("-2 week");
         $time_min = date(DATE_MYSQL, $previous_week);
         $events = ProjectEvents::findNoSync($user->getContactId(), $time_min, 100);
         $events_inv = ProjectEvents::findNoSyncInvitations($user->getContactId(), $time_min, 100);
         try {
             if ($calendar_feng instanceof ExternalCalendar) {
                 $events_and_inv = array_merge($events, $events_inv);
                 foreach ($events_and_inv as $event) {
                     $this->update_event_on_google_calendar($event, $calendar_feng, $user, $service);
                 }
                 //we ask for events in this calendar in order to prevent checking the uploaded events on the import
                 try {
                     $now = strtotime("now");
                     $time_min = date(DATE_RFC3339, $now);
                     $optParams['timeMin'] = $time_min;
                     $events = $service->events->listEvents($calendar_feng->getOriginalCalendarId(), $optParams);
                 } catch (Exception $e) {
                     Logger::log("Fail to get events from feng external calendar: " . $calendar->getId());
                     Logger::log($e->getMessage());
                 }
                 //update the calendar token
                 $nextSyncToken = $events->getNextSyncToken();
                 if ($nextSyncToken) {
                     $calendar_feng->setExternalCalendarPropertyValue("syncToken", $nextSyncToken);
                 }
             } else {
                 //create feng calendar on google if not exists and save it on feng
                 $instalation = explode("/", ROOT_URL);
                 $instalation_name = end($instalation);
                 $calendar_name = lang('feng calendar', $instalation_name);
                 $calendar_exists = false;
                 //check if calendar exists
                 try {
                     $calendarList = $service->calendarList->listCalendarList();
                     while (true) {
                         foreach ($calendarList->getItems() as $calendarListEntry) {
                             if ($calendarListEntry->getSummary() == $calendar_name) {
                                 $calendar_exists = true;
                                 $external_calendar = array('original_calendar_id' => $calendarListEntry->getId(), 'title' => $calendarListEntry->getSummary(), 'calendar_status' => 1);
                                 break;
                             }
                         }
                         $pageToken = $calendarList->getNextPageToken();
                         if ($pageToken) {
                             $optParams = array('pageToken' => $pageToken);
                             $calendarList = $service->calendarList->listCalendarList($optParams);
                         } else {
                             break;
                         }
                     }
                 } catch (Exception $e) {
                     Logger::log("Fail to get calendars list from google: " . $user->getContactId());
                     throw $e;
                 }
                 if (!$calendar_exists) {
                     $new_calendar = new Google_Service_Calendar_Calendar();
                     $new_calendar->setSummary($calendar_name);
                     //$calendar->setTimeZone('America/Los_Angeles');
                     $createdCalendar = $service->calendars->insert($new_calendar);
                     $external_calendar = array('original_calendar_id' => $createdCalendar->getId(), 'title' => $createdCalendar->getSummary(), 'calendar_status' => 1);
                 }
                 $calendar = new ExternalCalendar();
                 $calendar->setOriginalCalendarId($external_calendar['original_calendar_id']);
                 //$calendar->setCalendarVisibility($calendar_visibility);
                 $calendar->setCalendarName($external_calendar['title']);
                 $calendar->setExtCalUserId($user->getId());
                 $calendar->setCalendarFeng(1);
                 $calendar->setSync(1);
                 $calendar->save();
             }
             flash_success(lang('success add sync'));
             ajx_current("reload");
         } catch (Exception $e) {
             Logger::log($e->getMessage());
         }
     }
 }
 /**
  * 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;
 }
예제 #15
0
} else {
    $birthdays = array();
}
$result = array();
if ($milestones) {
    $result = array_merge($result, $milestones);
}
if (isset($tasks)) {
    foreach ($tasks as $task) {
        $result = array_merge($result, replicateRepetitiveTaskForCalendar($task, $date_start, $date_end));
    }
}
if (is_array($birthdays) && count($birthdays) > 0) {
    $result = array_merge($result, $birthdays);
}
$all_events = ProjectEvents::getRangeProjectEvents($date_start, $date_end, $user_filter, $status_filter);
$all_event_ids = array();
foreach ($all_events as $aev) {
    $all_event_ids[] = $aev->getId();
}
$read_events = array();
if (count($all_event_ids) > 0) {
    $read_rows = DB::executeAll("SELECT rel_object_id FROM " . TABLE_PREFIX . "read_objects WHERE is_read=1 AND contact_id=" . logged_user()->getId() . " AND rel_object_id IN (" . implode(",", $all_event_ids) . ")");
    if (is_array($read_rows)) {
        foreach ($read_rows as $rr) {
            $read_events[$rr['rel_object_id']] = 1;
        }
    }
}
// generate repetitive event instances
$repeated_instances = array();
 public function markasunread()
 {
     $ev_ids = explode(',', array_var($_GET, 'ids', ''));
     if (!is_array($ev_ids) || count($ev_ids) == 0) {
         flash_error(lang('no objects selected'));
         ajx_current("empty");
         return;
     }
     $events = array();
     foreach ($ev_ids as $id) {
         $event = ProjectEvents::findById($id);
         $event->setIsRead(logged_user()->getId(), false);
     }
     ajx_current("reload");
 }
예제 #17
0
 function list_objects()
 {
     //alert("debugging. remove this line");ajx_current('empty'); return array() ; //TODO remove this line
     /* get query parameters */
     $filesPerPage = config_option('files_per_page');
     $start = array_var($_GET, 'start') ? (int) array_var($_GET, 'start') : 0;
     $limit = array_var($_GET, 'limit') ? array_var($_GET, 'limit') : $filesPerPage;
     $order = array_var($_GET, 'sort');
     $ignore_context = (bool) array_var($_GET, 'ignore_context');
     if ($order == "dateUpdated") {
         $order = "updated_on";
     } elseif ($order == "dateArchived") {
         $order = "archived_on";
     } elseif ($order == "dateDeleted") {
         $order = "trashed_on";
     }
     $orderdir = array_var($_GET, 'dir');
     $page = (int) ($start / $limit) + 1;
     $hide_private = !logged_user()->isMemberOfOwnerCompany();
     $typeCSV = array_var($_GET, 'type');
     $types = null;
     if ($typeCSV) {
         $types = explode(",", $typeCSV);
     }
     $name_filter = mysql_escape_string(array_var($_GET, 'name'));
     $linked_obj_filter = array_var($_GET, 'linkedobject');
     $object_ids_filter = '';
     if (!is_null($linked_obj_filter)) {
         $linkedObject = Objects::findObject($linked_obj_filter);
         $objs = $linkedObject->getLinkedObjects();
         foreach ($objs as $obj) {
             $object_ids_filter .= ($object_ids_filter == '' ? '' : ',') . $obj->getId();
         }
     }
     $filters = array();
     if (!is_null($types)) {
         $filters['types'] = $types;
     }
     if (!is_null($name_filter)) {
         $filters['name'] = $name_filter;
     }
     if ($object_ids_filter != '') {
         $filters['object_ids'] = $object_ids_filter;
     }
     $user = array_var($_GET, 'user');
     $trashed = array_var($_GET, 'trashed', false);
     $archived = array_var($_GET, 'archived', false);
     /* if there's an action to execute, do so */
     if (array_var($_GET, 'action') == 'delete') {
         $ids = explode(',', array_var($_GET, 'objects'));
         $result = ContentDataObjects::listing(array("extra_conditions" => " AND o.id IN (" . implode(",", $ids) . ") ", "include_deleted" => true));
         $objects = $result->objects;
         list($succ, $err) = $this->do_delete_objects($objects);
         if ($err > 0) {
             flash_error(lang('error delete objects', $err));
         } else {
             Hook::fire('after_object_delete_permanently', $ids, $ignored);
             flash_success(lang('success delete objects', $succ));
         }
     } else {
         if (array_var($_GET, 'action') == 'delete_permanently') {
             $ids = explode(',', array_var($_GET, 'objects'));
             //$result = Objects::getObjectsFromContext(active_context(), null, null, true, false, array('object_ids' => implode(",",$ids)));
             $objects = Objects::instance()->findAll(array("conditions" => "id IN (" . implode(",", $ids) . ")"));
             list($succ, $err) = $this->do_delete_objects($objects, true);
             if ($err > 0) {
                 flash_error(lang('error delete objects', $err));
             }
             if ($succ > 0) {
                 Hook::fire('after_object_delete_permanently', $ids, $ignored);
                 flash_success(lang('success delete objects', $succ));
             }
         } else {
             if (array_var($_GET, 'action') == 'markasread') {
                 $ids = explode(',', array_var($_GET, 'objects'));
                 list($succ, $err) = $this->do_mark_as_read_unread_objects($ids, true);
             } else {
                 if (array_var($_GET, 'action') == 'markasunread') {
                     $ids = explode(',', array_var($_GET, 'objects'));
                     list($succ, $err) = $this->do_mark_as_read_unread_objects($ids, false);
                 } else {
                     if (array_var($_GET, 'action') == 'empty_trash_can') {
                         $result = Objects::getObjectsFromContext(active_context(), 'trashed_on', 'desc', true);
                         $objects = $result->objects;
                         list($succ, $err) = $this->do_delete_objects($objects, true);
                         if ($err > 0) {
                             flash_error(lang('error delete objects', $err));
                         }
                         if ($succ > 0) {
                             flash_success(lang('success delete objects', $succ));
                         }
                     } else {
                         if (array_var($_GET, 'action') == 'archive') {
                             $ids = explode(',', array_var($_GET, 'objects'));
                             list($succ, $err) = $this->do_archive_unarchive_objects($ids, 'archive');
                             if ($err > 0) {
                                 flash_error(lang('error archive objects', $err));
                             } else {
                                 flash_success(lang('success archive objects', $succ));
                             }
                         } else {
                             if (array_var($_GET, 'action') == 'unarchive') {
                                 $ids = explode(',', array_var($_GET, 'objects'));
                                 list($succ, $err) = $this->do_archive_unarchive_objects($ids, 'unarchive');
                                 if ($err > 0) {
                                     flash_error(lang('error unarchive objects', $err));
                                 } else {
                                     flash_success(lang('success unarchive objects', $succ));
                                 }
                             } else {
                                 if (array_var($_GET, 'action') == 'unclassify') {
                                     $ids = explode(',', array_var($_GET, 'objects'));
                                     $err = 0;
                                     $succ = 0;
                                     foreach ($ids as $id) {
                                         $split = explode(":", $id);
                                         $type = $split[0];
                                         if (Plugins::instance()->isActivePlugin('mail') && $type == 'MailContents') {
                                             $email = MailContents::findById($split[1]);
                                             if (isset($email) && !$email->isDeleted() && $email->canEdit(logged_user())) {
                                                 if (MailController::do_unclassify($email)) {
                                                     $succ++;
                                                 } else {
                                                     $err++;
                                                 }
                                             } else {
                                                 $err++;
                                             }
                                         }
                                     }
                                     if ($err > 0) {
                                         flash_error(lang('error unclassify emails', $err));
                                     } else {
                                         flash_success(lang('success unclassify emails', $succ));
                                     }
                                 } else {
                                     if (array_var($_GET, 'action') == 'restore') {
                                         $errorMessage = null;
                                         $ids = explode(',', array_var($_GET, 'objects'));
                                         $success = 0;
                                         $error = 0;
                                         foreach ($ids as $id) {
                                             $obj = Objects::findObject($id);
                                             if ($obj->canDelete(logged_user())) {
                                                 try {
                                                     $obj->untrash($errorMessage);
                                                     if ($obj->getObjectTypeId() == 11) {
                                                         $event = ProjectEvents::findById($obj->getId());
                                                         if ($event->getExtCalId() != "") {
                                                             $this->created_event_google_calendar($obj, $event);
                                                         }
                                                     }
                                                     ApplicationLogs::createLog($obj, ApplicationLogs::ACTION_UNTRASH);
                                                     $success++;
                                                 } catch (Exception $e) {
                                                     $error++;
                                                 }
                                             } else {
                                                 $error++;
                                             }
                                         }
                                         if ($success > 0) {
                                             flash_success(lang("success untrash objects", $success));
                                         }
                                         if ($error > 0) {
                                             $errorString = is_null($errorMessage) ? lang("error untrash objects", $error) : $errorMessage;
                                             flash_error($errorString);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $filterName = array_var($_GET, 'name');
     $result = null;
     $context = active_context();
     $obj_type_types = array('content_object', 'dimension_object');
     if (array_var($_GET, 'include_comments')) {
         $obj_type_types[] = 'comment';
     }
     $type_condition = "";
     if ($types) {
         $type_condition = " AND name IN ('" . implode("','", $types) . "')";
     }
     $res = DB::executeAll("SELECT id from " . TABLE_PREFIX . "object_types WHERE type IN ('" . implode("','", $obj_type_types) . "') AND name <> 'file revision' {$type_condition} ");
     $type_ids = array();
     foreach ($res as $row) {
         if (ObjectTypes::isListableObjectType($row['id'])) {
             $types_ids[] = $row['id'];
         }
     }
     //Hook::fire('list_objects_type_ids', null, $types_ids);
     $type_ids_csv = implode(',', $types_ids);
     $extra_conditions = array();
     $extra_conditions[] = "object_type_id in ({$type_ids_csv})";
     if ($name_filter) {
         $extra_conditions[] = "name LIKE '%{$name_filter}%'";
     }
     //$pagination = Objects::getObjects($context,$start,$limit,$order,$orderdir,$trashed,$archived, $filters,$start, $limit, $obj_type_types);
     $pagination = ContentDataObjects::listing(array("start" => $start, "limit" => $limit, "order" => $order, "order_dir" => $orderdir, "trashed" => $trashed, "archived" => $archived, "types" => $types, "count_results" => false, "extra_conditions" => " AND " . implode(" AND ", $extra_conditions), "ignore_context" => $ignore_context));
     $result = $pagination->objects;
     $total_items = $pagination->total;
     if (!$result) {
         $result = array();
     }
     /* prepare response object */
     $info = array();
     foreach ($result as $obj) {
         $info_elem = $obj->getArrayInfo($trashed, $archived);
         $instance = Objects::instance()->findObject($info_elem['object_id']);
         $info_elem['url'] = $instance->getViewUrl();
         /* @var $instance Contact  */
         if ($instance instanceof Contact) {
             if ($instance->isCompany()) {
                 $info_elem['icon'] = 'ico-company';
                 $info_elem['type'] = 'company';
             }
         } else {
             if ($instance instanceof ProjectFile) {
                 $info_elem['mimeType'] = $instance->getTypeString();
             }
         }
         $info_elem['isRead'] = $instance->getIsRead(logged_user()->getId());
         $info_elem['manager'] = get_class($instance->manager());
         $info_elem['memPath'] = json_encode($instance->getMembersToDisplayPath());
         $info[] = $info_elem;
     }
     $listing = array("totalCount" => $total_items, "start" => $start, "objects" => $info);
     ajx_extra_data($listing);
     tpl_assign("listing", $listing);
     if (isset($reload) && $reload) {
         ajx_current("reload");
     } else {
         ajx_current("empty");
     }
 }
예제 #18
0
 /**
  * This function will return all events in a project
  *
  * @param void
  * @return array
  */
 function getAllEvents()
 {
     if (is_null($this->all_events)) {
         $this->all_events = ProjectEvents::getAllEventsByProject($this);
     }
     // if
     return $this->all_events;
 }
예제 #19
0
 /**
  * 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);
 }
 function findByEventAndRelated($event_id, $original_event_id)
 {
     return ProjectEvents::findAll(array('conditions' => array('(`original_event_id` = ? OR `object_id` = ?) AND `object_id` <> ?', $original_event_id, $original_event_id, $event_id)));
 }
         </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) {
예제 #22
0
 function canAdd(Contact $user, $context, &$notAllowedMember = '')
 {
     return can_add($user, $context, ProjectEvents::instance()->getObjectTypeId(), $notAllowedMember);
 }
예제 #23
0
$use_24_hours = user_config_option('time_format_use_24');
$date_format = user_config_option('date_format');
if ($use_24_hours) {
    $timeformat = 'G:i';
} else {
    $timeformat = 'g:i A';
}
echo stylesheet_tag('event/day.css');
$today = DateTimeValueLib::now();
$today->add('h', logged_user()->getTimezone());
$currentday = $today->format("j");
$currentmonth = $today->format("n");
$currentyear = $today->format("Y");
$drawHourLine = $day == $currentday && $month == $currentmonth && $year == $currentyear;
$dtv = DateTimeValueLib::make(0, 0, 0, $month, $day, $year);
$result = ProjectEvents::getDayProjectEvents($dtv, $tags, active_project(), $user_filter, $status_filter);
if (!$result) {
    $result = array();
}
$alldayevents = array();
$milestones = ProjectMilestones::getRangeMilestonesByUser($dtv, $dtv, $user_filter != -1 ? $user : null, $tags, active_project());
$tasks = ProjectTasks::getRangeTasksByUser($dtv, $dtv, $user_filter != -1 ? $user : null, $tags, active_project());
$birthdays = Contacts::instance()->getRangeContactsByBirthday($dtv, $dtv);
foreach ($result as $key => $event) {
    if ($event->getTypeId() > 1) {
        $alldayevents[] = $event;
        unset($result[$key]);
    }
}
if ($milestones) {
    $alldayevents = array_merge($alldayevents, $milestones);
예제 #24
0
 function check_related_event(){
     ajx_current("empty");
     //I find all those related to the task to find out if the original
     $event_related = ProjectEvents::findByRelated(array_var($_REQUEST, 'related_id'));
     if(!$event_related){
         $event_related = ProjectEvents::findById(array_var($_REQUEST, 'related_id'));
         //is not the original as the original look plus other related
         if($event_related->getOriginalEventId() != "0"){
             ajx_extra_data(array("status" => true));
         }else{
             ajx_extra_data(array("status" => false));
         }                
     }else{
         ajx_extra_data(array("status" => true));
     }
 }
예제 #25
0
     //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>';
예제 #26
0
파일: index.php 프로젝트: rorteg/fengoffice
 $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 .= "&nbsp;";
 $output .= "</div>";
 // This loop writes the events for the day in the cell
 if (is_numeric($w)) {
     //$result = ProjectEvents::getDayProjectEvents($dtv, $tags, active_project(), logged_user()->getId(), ' 0 1 3');
     $result = ProjectEvents::getDayProjectEvents($dtv, active_context(), logged_user()->getId(), ' 0 1 3');
     if (!$result) {
         $result = array();
     }
     if (!empty($milestones)) {
         $result = array_merge($result, $milestones);
     }
     if (!empty($tasks)) {
         $result = array_merge($result, $tasks);
     }
     if (!empty($birthdays)) {
         $result = array_merge($result, $birthdays);
     }
     if (count($result) < 1) {
         $output .= "&nbsp;";
     } else {
예제 #27
0
if ($use_24_hours) {
    $timeformat = 'G:i';
} else {
    $timeformat = 'g:i A';
}
echo stylesheet_tag('event/day.css');
//today in gmt 0
$today = DateTimeValueLib::now();
//user today
//	$today->add('h', logged_user()->getTimezone());
$currentday = $today->format("j");
$currentmonth = $today->format("n");
$currentyear = $today->format("Y");
$drawHourLine = $day == $currentday && $month == $currentmonth && $year == $currentyear;
$dtv = DateTimeValueLib::make(0, 0, 0, $month, $day, $year);
$result = ProjectEvents::getDayProjectEvents($dtv, active_context(), $user_filter, $status_filter);
if (!$result) {
    $result = array();
}
$alldayevents = array();
$milestones = ProjectMilestones::getRangeMilestones($dtv, $dtv);
if ($task_filter != "hide") {
    $tasks = ProjectTasks::getRangeTasksByUser($dtv, $dtv, $user_filter != -1 ? $user : null, $task_filter);
}
if (user_config_option('show_birthdays_in_calendar')) {
    $birthdays = Contacts::instance()->getRangeContactsByBirthday($dtv, $dtv, active_context_members(false));
} else {
    $birthdays = array();
}
foreach ($result as $key => $event) {
    if ($event->getTypeId() > 1) {
예제 #28
0
function export_google_calendar() {
    _log("export with google calendar...");
    ProjectEvents::export_google_calendar();
    _log("end export with google calendar...");
}
예제 #29
0
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;
}
예제 #30
0
        $duration .= lang('CAL_HOUR');
    }
    if ($durmin != "0") {
        $duration .= ", " . $durmin . " " . lang('CAL_MINUTES_SHORT');
    }
    // organize other time options for the event
    $typeofevent = $event->getTypeId();
    if ($typeofevent == "2") {
        $duration = lang('CAL_FULL_DAY');
    } elseif ($typeofevent == "3") {
        $time = lang('CAL_NOT_SPECIFIED');
        $duration = lang('CAL_NOT_SPECIFIED');
    } elseif ($typeofevent == "4") {
        $duration = lang('CAL_NOT_SPECIFIED');
    }
    $permission = ProjectEvents::findById($id)->canEdit(logged_user());
    ?>
<div style="padding:7px;">
<div class="event" style="height:100%;">

<?php 
    $title = format_descriptive_date($event->getStart()) . ' - ' . clean($event->getSubject());
    $description = $event->getTypeId() == 2 ? lang('CAL_FULL_DAY') : lang('CAL_TIME') . ": {$time}";
    tpl_assign('description', $description);
    $att_form = '';
    if (!$event->isNew() && !$event->isTrashed()) {
        $event_inv = EventInvitations::findById(array('event_id' => $event->getId(), 'user_id' => logged_user()->getId()));
        if ($event_inv != null) {
            $event->addInvitation($event_inv);
            $event_inv_state = $event_inv->getInvitationState();
            $options = array(option_tag(lang('yes'), 1, $event_inv_state == 1 ? array('selected' => 'selected') : null), option_tag(lang('no'), 2, $event_inv_state == 2 ? array('selected' => 'selected') : null), option_tag(lang('maybe'), 3, $event_inv_state == 3 ? array('selected' => 'selected') : null));