/** * Return manager instance * * @access protected * @param void * @return ObjectReminderTypes */ function manager() { if (!$this->manager instanceof ObjectReminderTypes) { $this->manager = ObjectReminderTypes::instance(); } return $this->manager; }
/** * Return manager instance * * @access protected * @param void * @return ObjectReminderTypes */ function manager() { if(!($this->manager instanceof ObjectReminderTypes)) $this->manager = ObjectReminderTypes::instance(); return $this->manager; } // manager
function render_add_reminders_config($reminder_opt) { $defaults = array(); $def = explode(",", user_config_option($reminder_opt)); $default_defaults = array( 'type' => array_var($def, 0), 'duration' => array_var($def, 1), 'duration_type' => array_var($def, 2) ); foreach ($default_defaults as $k => $v) { if (!isset($defaults[$k])) $defaults[$k] = $v; } $types = ObjectReminderTypes::findAll(); $typecsv = array(); foreach ($types as $type) { $typecsv []= $type->getName(); } $durations = array(0,1,2,5,10,15,30); $duration_types = array("1" => "minutes","60" => "hours","1440" => "days","10080" => "weeks"); $output = '<select name="options['.$reminder_opt.'][reminder_type]">'; foreach ($typecsv as $type) { $output .= '<option value="' . $type . '"'; if ($type == array_var($defaults, 'type')) { $output .= ' selected="selected"'; } $output .= '>' . lang($type) . '</option>'; } $output .= '</select>'; $output .= '<select name="options['.$reminder_opt.'][reminder_duration]">'; foreach ($durations as $duration) { $output .= '<option value="' . $duration . '"'; if ($duration == array_var($defaults, 'duration')) { $output .= ' selected="selected"'; } $output .= '>' . $duration . '</option>'; } $output .= '</select>'; $output .= '<select name="options['.$reminder_opt.'][reminder_duration_type]">'; foreach ($duration_types as $key => $value) { $output .= '<option value="' . $key . '"'; if ($key == array_var($defaults, 'duration_type')) { $output .= ' selected="selected"'; } $output .= '>' . lang($value) . '</option>'; } $output .= '</select>'; return $output; }
/** * 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, 'ObjectReminderTypes')) { return parent::paginate($arguments, $items_per_page, $current_page); } else { return ObjectReminderTypes::instance()->paginate($arguments, $items_per_page, $current_page); //$instance =& ObjectReminderTypes::instance(); //return $instance->paginate($arguments, $items_per_page, $current_page); } // if }
function render_add_reminders($object, $context, $defaults = null, $genid = null) { require_javascript('og/Reminders.js'); if (!is_array($defaults)) { $defaults = array(); } $default_defaults = array('type' => 'reminder_popup', 'duration' => '15', 'duration_type' => '1', 'for_subscribers' => true); foreach ($default_defaults as $k => $v) { if (!isset($defaults[$k])) { $defaults[$k] = $v; } } if (is_null($genid)) { $genid = gen_id(); } $types = ObjectReminderTypes::findAll(); $typecsv = ""; foreach ($types as $type) { if ($typecsv != "") { $typecsv .= ","; } $typecsv .= '"' . $type->getName() . '"'; } $output = ' <div id="' . $genid . '" class="og-add-reminders"> <a id="' . $genid . '-link" href="#" onclick="og.addReminder(this.parentNode, \'' . $context . '\', \'' . $defaults['type'] . '\', \'' . $defaults['duration'] . '\', \'' . $defaults['duration_type'] . '\', \'' . $defaults['for_subscribers'] . '\', this);return false;">' . lang("add object reminder") . '</a> </div> <script> og.reminderTypes = [' . $typecsv . ']; </script> '; if ($object->isNew()) { $output .= '<script>og.addReminder(document.getElementById("' . $genid . '"), \'' . $context . '\', \'' . $defaults['type'] . '\', \'' . $defaults['duration'] . '\', \'' . $defaults['duration_type'] . '\', \'' . $defaults['for_subscribers'] . '\', document.getElementById("' . $genid . '-link"));</script>'; } else { $reminders = ObjectReminders::getAllRemindersByObjectAndUser($object, logged_user(), $context, true); foreach ($reminders as $reminder) { $mins = $reminder->getMinutesBefore(); if ($mins % 10080 == 0) { $duration = $mins / 10080; $duration_type = "10080"; } else { if ($mins % 1440 == 0) { $duration = $mins / 1440; $duration_type = "1440"; } else { if ($mins % 60 == 0) { $duration = $mins / 60; $duration_type = "60"; } else { $duration = $mins; $duration_type = "1"; } } } $type = $reminder->getType(); $forSubscribers = $reminder->getUserId() == 0 ? "true" : "false"; $output .= '<script>og.addReminder(document.getElementById("' . $genid . '"), "' . $context . '", "' . $type . '", "' . $duration . '", "' . $duration_type . '", ' . $forSubscribers . ', document.getElementById(\'' . $genid . '-link\'));</script>'; } // for } return $output; }