Example #1
0
 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;
 }
Example #2
0
 private function setup_object($page, $newpage = false)
 {
     if (!$page || !is_object($page)) {
         return null;
     }
     if ($this->title && MValidate::title($this->title)) {
         $page->title = $this->title;
     } else {
         echo $this->title;
         return mapi_report_message('Not a valid page title.');
     }
     $page->name = $this->name;
     if ($newpage) {
         if (!mapi_check_double('pages', 'name', $this->name)) {
             return mapi_report_message('Page with that name already exists.');
         }
     }
     if (in_array($this->type, $this->types)) {
         $page->type = $this->type;
     } else {
         $page->type = 'url';
     }
     if ($this->url && MValidate::url($this->url)) {
         $page->url = $this->url;
     } else {
         return mapi_report_message('Not a valid url.');
     }
     if ($this->blank && 1 == $this->blank) {
         $page->blank = 1;
     } else {
         $page->blank = 0;
     }
     if ($this->enabled && 1 == $this->enabled) {
         $page->enabled = 1;
     } else {
         $page->enabled = 0;
     }
     return true;
 }
Example #3
0
 private function setup_object($menu, $newmenu)
 {
     if (!$menu || !is_object($menu)) {
         return null;
     }
     if ($this->title && MValidate::title($this->title)) {
         $menu->title = $this->title;
     } else {
         return mapi_report_message('Not a valid title.');
     }
     $menu->name = $this->name;
     if ($newmenu) {
         if (!mapi_check_double('menus', 'name', $this->name)) {
             return mapi_report_message('Menu with that name already exists.');
         }
     }
     $menu->pages = $this->save_pages();
     if ($this->enabled && 1 == $this->enabled) {
         $menu->enabled = 1;
     } else {
         $menu->enabled = 0;
     }
     return true;
 }
 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;
 }