Пример #1
0
 /**
  * Prepares and shows the devices list (cmd-my-devices)
  *
  * @param array args (not used)
  */
 public function get_my_devices_list(array $args)
 {
     // check if is logged in
     if (!$this->mvc->authentication->is_user()) {
         return;
     }
     // check if user has at least one provider
     $this->data['user_has_provider'] = com_meego_devprogram_provutils::user_has_providers();
     if (!$this->data['user_has_provider']) {
         return false;
     }
     // get own devices
     // and the ones that belong to providers the user is also member of
     $this->data['my_devices'] = com_meego_devprogram_devutils::get_devices_of_current_user();
 }
Пример #2
0
 /**
  * Loads a form
  */
 public function load_form()
 {
     $this->form = midgardmvc_helper_forms_mgdschema::create($this->object, false, 'label_program_', 'tip_program_');
     # we have to alter the submit button and three fields on the form
     $this->form->set_submit('form-submit', $this->mvc->i18n->get('command_save'));
     # remove the name field, we will genarate it from title
     $this->form->__unset('name');
     # change the default widget of duedate field
     $object_end = $this->object->duedate;
     if ($object_end->getTimestamp() <= 0) {
         $new_end = new DateTime('last day of next month');
         $object_end->setTimestamp($new_end->getTimestamp());
     }
     $duedate = new midgardmvc_helper_forms_field_text('duedate', true);
     $duedate->set_value($object_end);
     $widget = $duedate->set_widget('date');
     $widget->set_label($this->mvc->i18n->get('label_program_duedate'));
     $this->form->__set('duedate', $duedate);
     # change the default widget of device field
     $devices = com_meego_devprogram_devutils::get_devices_of_current_user();
     foreach ($devices as $device) {
         $device_options[] = array('description' => $device->title, 'value' => $device->id);
     }
     $device = new midgardmvc_helper_forms_field_integer('device', true);
     $device->set_value($this->object->device);
     $widget = $device->set_widget('selectoption');
     $widget->set_label($this->mvc->i18n->get('label_program_device'));
     if (is_array($device_options)) {
         $widget->set_options($device_options);
     }
     $this->form->__set('device', $device);
 }