Beispiel #1
0
 static function register()
 {
     if (!MValidate::password(MGet::string('pass'))) {
         return mapi_report('Invalid password.');
     }
     if (MGet::string('pass') !== MGet::string('pass_repeat')) {
         return mapi_report('Passwords do not match.');
     }
     $user = MObject::create('user');
     $user->set_username(MGet::string('user'));
     $user->set_name(MGet::string('name'));
     $user->set_email(MGet::string('email'));
     $reg_group = MObject::get('preference', 'new_user_default_group');
     $group = null;
     if (!$reg_group || $reg_group->get_value()) {
         $group = 3;
     }
     if ($reg_group->get_value() < 1 || $reg_group->get_value() > 3) {
         $group = 3;
     }
     if (!$group) {
         $group = $reg_group->get_value();
     }
     $user->set_group_id($group);
     $user->set_activation(urlencode(MCrypt::encrypt(mapi_random(24))));
     $user->set_enabled(0);
     $user->add(MGet::string('pass'));
     if (0 == MMessaging::any_errors() + MMessaging::any_warnings()) {
         self::send_reg_email($user);
         $_POST['user'] = '';
         $_POST['name'] = '';
         $_POST['email'] = '';
     }
 }
Beispiel #2
0
 static function add_category()
 {
     $category = MObject::create('category');
     $category->set_title(MGet::string('category_title'));
     $category->add();
     if (0 == MMessaging::any_errors() + MMessaging::any_warnings()) {
         return $category;
     } else {
         return false;
     }
 }
Beispiel #3
0
 static function add_menu()
 {
     $menu = MObject::create('menu');
     $menu->set_title(MGet::string('menu_title'));
     $menu->add();
     if (0 == MMessaging::any_errors() + MMessaging::any_warnings()) {
         return $menu;
     } else {
         return false;
     }
 }
Beispiel #4
0
 static function add_user()
 {
     $user = MObject::create('user');
     $user->set_group_id(MGet::int('user_group_id'));
     $user->set_username(MGet::string('user_username'));
     $user->set_email(MGet::string('user_email'));
     $user->set_name(MGet::string('user_name'));
     if (MGet::string('user_pass') != MGet::string('user_pass_repeat')) {
         return mapi_report_message('Passwords do not match');
     }
     $user->add(MGet::string('user_pass'));
     if (0 == MMessaging::any_errors() + MMessaging::any_warnings()) {
         return $user;
     } else {
         return false;
     }
 }
Beispiel #5
0
 static function add_page()
 {
     $page = MObject::create('page');
     $page->set_type(MGet::string('page_type'));
     $page->set_title(MGet::string('page_title'));
     $page->set_url(MGet::string('page_url'));
     if (1 == MGet::int('page_on_blank')) {
         $page->set_on_blank(1);
     } else {
         $page->set_on_blank(0);
     }
     $page->add();
     if (0 == MMessaging::any_errors() + MMessaging::any_warnings()) {
         return $page;
     } else {
         return false;
     }
 }
Beispiel #6
0
 static function import_content()
 {
     if (!isset($_POST['content_type'])) {
         return false;
     }
     $content = MObject::create(MGet::string('content_type'));
     if (!$content) {
         return false;
     }
     $content->set_title(MGet::string('content_title'));
     $content->set_license(2);
     $content->set_address(MGet::string('content_address'));
     $content->set_lat(MGet::double('content_lat'));
     $content->set_lng(MGet::double('content_lng'));
     if ('event' == MGet::string('content_type')) {
         $content->set_start(MGet::string('content_start'));
         $content->set_end(MGet::string('content_end'));
     }
     $content->set_text(MGet::string('content_text'));
     $content->add();
     if (0 == MMessaging::any_errors() + MMessaging::any_warnings()) {
         return $content;
     } else {
         return false;
     }
 }
Beispiel #7
0
 static function import_content($data)
 {
     $encdata = json_decode(base64_decode($data));
     $config = $encdata->ini;
     $cat = $config->category;
     $TitleName = $config->Title;
     $AddressName = $config->Address;
     $ZipName = $config->ZIP;
     $CityName = $config->City;
     $category = new M_Category($cat);
     $category->set_title($cat);
     $category->add();
     $desc_data = explode(",", $config->description);
     $t = 0;
     foreach ($encdata->xml as $place) {
         $content = MObject::create('place');
         $TheTitle = $place->{$TitleName};
         if (empty($TheTitle)) {
             $TheTitle = $place->{'@attributes'}->{$TitleName};
         }
         if (empty($TheTitle)) {
             $TheTitle = 'Empty title ' . ++$t;
         }
         $content->set_title($TheTitle);
         $content->set_address($place->{$AddressName} . ", " . $place->{$ZipName} . ", " . $place->{$CityName});
         $content->set_lat($place->lat);
         $content->set_lng($place->lng);
         $content->set_license(2);
         $text = "";
         foreach ($desc_data as $desc) {
             if ("NL" == substr($desc, -2)) {
                 $newline = "<br />";
             } else {
                 $newline = ", ";
             }
             $attr = array_search(strtolower(rtrim($desc, 'NL')), array_map('strtolower', (array) $config));
             if (!empty($attr)) {
                 $pre_text = $place->{$attr};
                 if (is_string($pre_text)) {
                     $text .= rtrim($desc, 'NL') . ": " . $pre_text . $newline;
                 } else {
                     if (strtolower($desc) == 'desc_only') {
                         $text .= $place->desc_only;
                     }
                 }
             } else {
             }
         }
         $content->set_text($text);
         $content->add();
         $MetaArray = (array) $place;
         $MetaArray = array_filter($MetaArray);
         foreach ($config as $key => $value) {
             $key = trim($key);
             $value = trim($value);
             if (isset($MetaArray[$value]) && $value != 'desc_only') {
                 $DescVal = trim($MetaArray[$value]);
                 if (!empty($DescVal) && !empty($key)) {
                     $content->add_meta($key, $DescVal);
                 }
             }
         }
         $category->add_content($content->get_id());
     }
     $category->update();
     return true;
 }