Пример #1
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;
     }
 }
Пример #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;
     }
 }
Пример #3
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;
     }
 }
Пример #4
0
function mapi_report_message($message = null, $type = 'warning')
{
    if (!$message) {
        return null;
    }
    switch ($type) {
        case 'error':
            MMessaging::add_error($message);
            break;
        case 'warning':
            MMessaging::add_warning($message);
            break;
        case 'success':
            MMessaging::add_success($message);
            break;
    }
    return null;
}
Пример #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;
     }
 }
Пример #6
0
 public function __construct()
 {
     MMessaging::init();
     $SysConf = new MSettings();
     if (is_array($SysConf::$coords)) {
         global $coords;
         $coords['lat'] = $SysConf::$coords['lat'];
         $coords['lng'] = $SysConf::$coords['lng'];
     } elseif (isset($SysConf::$location)) {
         if (MValidate::address($SysConf::$location)) {
             global $geocoder;
             global $coords;
             try {
                 $geocode = $geocoder->geocode($SysConf::$location);
                 $coords['lat'] = $geocode->getLatitude();
                 $coords['lng'] = $geocode->getLongitude();
             } catch (Exception $e) {
             }
         }
     } else {
         if (MValidate::address(MSettings::$location)) {
             global $geocoder;
             global $coords;
             try {
                 $geocode = $geocoder->geocode(MSettings::$location);
                 $coords['lat'] = $geocode->getLatitude();
                 $coords['lng'] = $geocode->getLongitude();
             } catch (Exception $e) {
             }
         }
     }
     $routing = new M_Route();
     $module = new M_Module();
     $module_instance = $module->instance($routing->get_module(), $routing->get_task(), $routing->get_object());
     $template = new M_Template();
     $template_instance = $template->instance($module_instance);
 }
Пример #7
0
 private static function send_reg_email($user)
 {
     if (!is_object($user)) {
         return null;
     }
     if (MValidate::email(MSettings::$reg_email)) {
         $from = MSettings::$reg_email;
     } else {
         return null;
     }
     if (MValidate::email($user->get_email())) {
         $to = $user->get_email();
     } else {
         return null;
     }
     if (empty(MSettings::$domain)) {
         return null;
     }
     if (empty(MSettings::$reg_email_user)) {
         return null;
     }
     if (empty(MSettings::$reg_email_pass)) {
         return null;
     }
     if (empty(MSettings::$reg_email_host)) {
         return null;
     }
     if (!strlen($user->get_activation()) > 0) {
         return null;
     }
     $url = mapi_install_url() . 'manager/?module=register&activate=1&c=' . $user->get_activation();
     $body = "";
     $body .= "Welcome to " . MSettings::$domain . "\n\n";
     $body .= "To access the #mappiamo backend, please activate your account by clicking on the link below:\n";
     $body .= $url . "\n\n";
     $body .= "If the registration is not done by You, please send us an abuse letter by replying to this mail.\n\n";
     $body .= "Sincerely\n";
     $body .= MSettings::$domain;
     $message = Swift_Message::newInstance();
     $message->setSubject('Welcome to ' . MSettings::$sitename);
     $message->setFrom(array($from));
     $message->setTo(array($to => $user->get_name()));
     $message->setBody($body);
     $transport = Swift_SmtpTransport::newInstance(MSettings::$reg_email_host, 25)->setUsername(MSettings::$reg_email_user)->setPassword(MSettings::$reg_email_pass);
     $mailer = Swift_Mailer::newInstance($transport);
     if (!$mailer->send($message)) {
         $user->delete();
         MMessaging::clear();
         mapi_report('There was a problem. Please try again later.');
     } else {
         self::send_notification($user);
     }
 }
Пример #8
0
<div class="m-content-header">
		<h3 class="hidden-xs hidden-sm"><span class="glyphicon glyphicon-cog"></span>XML Importer</h3>
</div>

<?php 
$crumbs = array('mxmlimport' => array('title' => 'XML Importer'));
//$groups = mapi_list( 'user_groups' );
?>

<?php 
MHTML::breadcrumb($crumbs);
?>

<?php 
MMessaging::show();
?>


<form method="post">

		

		<div class="row">
				<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8">
						<br />
						<h4>Data preview: </h4><br />
						
								<?php 
?>
								
Пример #9
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;
     }
 }
Пример #10
0
 public static function get_instance()
 {
     if (!self::$_instance instanceof MMessaging) {
         self::$_instance = new MMessaging();
     }
     return self::$_instance;
 }
Пример #11
0
 static function clear()
 {
     self::$errors = array();
     self::$warnings = array();
     self::$success = array();
     self::clear_from_session();
 }