function mapi_list_page_menus($id) { if (!MValidate::id($id)) { return array(); } return ORM::for_table('menus')->where_like('pages', '%{' . intval($id) . '}%')->find_many(); }
protected function read($id) { if (!MValidate::id($id)) { return null; } $post = $this->read_record($id, $this->type); if ($post && $post->text) { $this->set_text($post->text); } }
static function sef_name($value) { if (!MValidate::string($value) && !MValidate::id($value)) { return false; } if (preg_match('/[^a-zA-Z0-9\\-éáűúőóüöíÉÁŰŐÚÓÜÖÍèçòàùì£ÈÀÒÙÌñÑ_’‘]/s', $value)) { return false; } return true; }
public function update() { if ($this->id && MValidate::id($this->id)) { $preference = ORM::for_table('preferences')->find_one($this->id); } if ($preference && $this->setup_object($preference)) { if ($preference->save()) { return true; } else { return false; } } }
protected function read($id) { if (!MValidate::id($id)) { return null; } $event = $this->read_record($id, $this->type); if ($event && is_object($event)) { if ($event->text) { $this->set_text($event->text); } if ($event->start) { $this->set_start($event->start); } if ($event->end) { $this->set_end($event->end); } } }
private function setup_object($user, $newuser = false) { if (!$user || !is_object($user)) { return null; } if ($this->group_id && MValidate::id($this->group_id)) { $user->group_id = $this->group_id; } else { return mapi_report_message('Not a valid group.'); } if ($this->username && MValidate::username($this->username)) { $user->username = $this->username; } else { return mapi_report_message('Not a valid username.'); } if (!$newuser) { if (!mapi_check_double('users', 'username', $this->username)) { return mapi_report_message('Username not available.'); } } if ($this->email && MValidate::email($this->email)) { $user->email = $this->email; } else { return mapi_report_message('Not a valid email address.'); } if ($this->name && MValidate::title($this->name)) { $user->name = $this->name; } else { return mapi_report_message('Not a valid name.'); } if ($this->enabled && 1 == $this->enabled) { $user->enabled = 1; } else { $user->enabled = 0; } return true; }
private function check_for_existing() { if (!isset($this->tables[$this->external]) || !MValidate::id($this->external_id)) { return false; } if (!MValidate::meta_name($this->name)) { return false; } $meta = ORM::for_table($this->tables[$this->external])->where('external_id', intval($this->external_id))->where('name', $this->name)->find_one(); return $meta; }
public function delete() { if ($this->id && MValidate::id($this->id)) { $page = ORM::for_table('pages')->find_one(intval($this->id)); if ($page->delete()) { return mapi_report_message('Sucessfully deleted.', 'success'); } } }
private function setup_object($record, $new = false) { if (!$record || !is_object($record)) { return null; } if ($this->title && MValidate::title($this->title)) { $record->title = $this->title; } else { return mapi_report_message('Not a valid content title: ' . $this->title); } if ($this->license && MValidate::id($this->license) && in_array($this->license, mapi_available_ids('licenses'))) { $record->license = $this->license; } else { return mapi_report_message('Not a valid content license: ' . $this->license); } $record->name = $this->name; if ($new) { if (!mapi_check_double('contents', 'name', $this->name)) { return mapi_report_message('Content with that name already exists: ' . $this->name); } } if ($this->address && MValidate::address($this->address)) { $record->address = $this->address; } else { return mapi_report_message('Not a valid content address: ' . $this->address); } if (isset($this->meta_name)) { if ($this->meta_name && MValidate::meta_name($this->meta_name)) { $record->meta_name = $this->meta_name; } else { return mapi_report_message('Not a valid meta name: ' . $this->meta_name); } } if (isset($this->meta_value)) { if ($this->meta_value && MValidate::meta_value($this->meta_value)) { $record->meta_value = $this->meta_value; } else { return mapi_report_message('Not a valid meta value: ' . $this->meta_value); } } if ($this->lat && MValidate::coord($this->lat)) { $record->lat = $this->lat; } else { return mapi_report_message('Not a valid latitude.'); } if ($this->lng && MValidate::coord($this->lng)) { $record->lng = $this->lng; } else { return mapi_report_message('Not a valid longitude.'); } if ($this->hits && $this->hits > 0) { $record->hits = intval($this->hits); } if ($this->parent) { $record->parent = intval($this->parent); } if ($this->language) { $record->language = strval($this->language); } if ($this->translation && 1 == $this->translation) { $record->translation = 1; } if ($this->enabled && 1 == $this->enabled) { $record->enabled = 1; } else { $record->enabled = 0; } return true; }
private function setup_object($category, $new = false) { if (!$category || !is_object($category)) { return null; } if ($this->title && MValidate::title($this->title)) { $category->title = $this->title; } else { return mapi_report_message('Not a valid category title: ' . $this->title); } $category->name = $this->name; if ($new) { if (!mapi_check_double('categories', 'name', $this->name)) { return mapi_report_message('Category with that name already exists: ' . $this->name); } } $category->contents = $this->save_contents(); if ($this->flagship) { if (MValidate::id($this->flagship)) { $category->flagship = $this->flagship; } else { return mapi_report_message('Not a valid flagship product.'); } } if ($this->enabled && 1 == $this->enabled) { $category->enabled = 1; } else { $category->enabled = 0; } return true; }