/** * Return manager instance * * @access protected * @param void * @return ContactWebpages */ function manager() { if (!$this->manager instanceof ContactWidgetOptions) { $this->manager = ContactWidgetOptions::instance(); } return $this->manager; }
function getContactWidgetSettings($contact) { if (!$contact instanceof Contact) { $contact = logged_user(); } $info = $this->getDefaultWidgetSettings(); $contact_widget = ContactWidgets::instance()->findOne(array('conditions' => array('contact_id = ? AND widget_name = ?', $contact->getId(), $this->getName()))); if ($contact_widget instanceof ContactWidget) { $info['order'] = $contact_widget->getOrder(); $info['section'] = $contact_widget->getSection(); $info['options'] = ContactWidgetOptions::instance()->getContactOptions($contact_widget->getWidgetName(), $contact->getId()); } return $info; }
/** * 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, 'ContactWidgetOptions')) { return parent::paginate($arguments, $items_per_page, $current_page); } else { return ContactWidgetOptions::instance()->paginate($arguments, $items_per_page, $current_page); } // if }
function configure_widgets_default_submit() { ajx_current("empty"); $widgets_data = array_var($_POST, 'widgets'); try { DB::beginWork(); foreach ($widgets_data as $name => $data) { $widget = Widgets::instance()->findOne(array('conditions' => array('name = ?', $name))); if (!$widget instanceof Widget) { continue; } $widget->setDefaultOrder($data['order']); $widget->setDefaultSection($data['section']); $widget->save(); if (isset($data['options']) && is_array($data['options'])) { foreach ($data['options'] as $opt_name => $opt_val) { $contact_widget_option = ContactWidgetOptions::instance()->findOne(array('conditions' => array('contact_id=0 AND widget_name=? AND `option`=?', $name, $opt_name))); if (!$contact_widget_option instanceof ContactWidgetOption) { continue; } $contact_widget_option->setValue($opt_val); $contact_widget_option->save(); } } } DB::commit(); evt_add('reload tab panel', 'overview-panel'); ajx_current("back"); } catch (Exception $e) { flash_error($e->getMessage()); DB::rollback(); } }
$startday = date("j") - date("N") + 1; // beginning of the week, monday } else { $startday = date("j") - date("w"); // beginning of the week, sunday } //user_config_option('show_two_weeks_calendar',null,logged_user()->getId())? $my_weeks = 2 : $my_weeks = 1 ; $my_weeks = 2; $endday = $startday + 7 * $my_weeks; $today = DateTimeValueLib::now()->add('h', logged_user()->getTimezone()); $currentday = $today->getDay(); $currentmonth = $today->getMonth(); $currentyear = $today->getYear(); $user_filter_myself = true; $user_filter = null; $w_option_user_filter = ContactWidgetOptions::instance()->getContactOption('calendar', logged_user()->getId(), 'filter_by_myself'); if (array_var($w_option_user_filter, 'option')) { $user_filter_myself = array_var($w_option_user_filter, 'value'); } if ($user_filter_myself) { $user_filter = logged_user(); } $date_start = new DateTimeValue(mktime(0, 0, 0, $currentmonth, $startday, $currentyear)); $date_end = new DateTimeValue(mktime(0, 0, 0, $currentmonth, $endday, $currentyear)); $tmp_tasks = ProjectTasks::instance()->getRangeTasksByUser($date_start, $date_end, $user_filter, null, false, true); $birthdays = Contacts::instance()->getRangeContactsByBirthday($date_start, $date_end); $milestones = ProjectMilestones::getRangeMilestones($date_start, $date_end); $tasks = array(); if ($tmp_tasks) { foreach ($tmp_tasks as $task) { $tasks = array_merge($tasks, replicateRepetitiveTaskForCalendarRawTask($task, $date_start, $date_end));
foreach ($context as $selection) { if ($selection instanceof Member) { $active_members[] = $selection; } } } if (count($active_members) > 0) { $mnames = array(); $allowed_contact_ids = array(); foreach ($active_members as $member) { $mnames[] = clean($member->getName()); } $widget_title = lang('late tasks and upcoming tasks') . ' ' . lang('in') . ' ' . implode(", ", $mnames); } $assigned_to_user = null; $w_option_assigned_to = ContactWidgetOptions::instance()->getContactOption('overdue_upcoming', logged_user()->getId(), 'assigned_to_user'); if (array_var($w_option_assigned_to, 'value')) { $assigned_to_user = array_var($w_option_assigned_to, 'value'); } // Not due tasks $not_due_tasks = ProjectTasks::getUpcomingWithoutDate($not_overdue_limit + 1, $assigned_to_user); if (count($not_due_tasks) > $not_overdue_limit) { $show_more = true; array_pop($not_due_tasks); } // Due Tasks $overdue_upcoming_objects = ProjectTasks::getOverdueAndUpcomingObjects($overdue_limit + 1, $assigned_to_user); // FIXME: performance Killer if (count($overdue_upcoming_objects) > $overdue_limit) { $show_more = true; array_pop($overdue_upcoming_objects);