Esempio n. 1
0
 static function import_facebook()
 {
     $results = array('header' => 'Import Facebook events', 'type' => 'event');
     $facebook = self::facebook_init();
     if (!$facebook) {
         mapi_report('Cannot download events, try again later.', 'error');
         return $results;
     }
     if (!$facebook->getUser()) {
         mapi_report('Please login first with your facebook account.');
         return $results;
     }
     try {
         $events = $facebook->api('/me/events', 'GET');
         if (isset($events['data']) && is_array($events['data']) && sizeof($events['data']) > 0) {
             $i = 0;
             foreach ($events['data'] as $event) {
                 if (isset($event['id'])) {
                     try {
                         $query = 'SELECT pic_big, description, creator FROM event WHERE eid = ' . $event['id'];
                         $object = $facebook->api(array('method' => 'fql.query', 'query' => $query));
                         $events['data'][$i]['uid'] = $object[0]['creator'];
                         $events['data'][$i]['image_url'] = $object[0]['pic_big'];
                         $events['data'][$i]['description'] = $object[0]['description'];
                     } catch (FacebookApiException $e) {
                     }
                     try {
                         $query = 'SELECT name FROM user WHERE uid = ' . $events['data'][$i]['uid'];
                         $object = $facebook->api(array('method' => 'fql.query', 'query' => $query));
                         $events['data'][$i]['host'] = $object[0]['name'];
                     } catch (FacebookApiException $e) {
                         mapi_report('Event data not complete.');
                     }
                     if (isset($events['data'][$i]['location']) && sizeof(isset($events['data'][$i]['location']))) {
                         global $geocoder;
                         $geocode = $geocoder->geocode($events['data'][$i]['location']);
                         $events['data'][$i]['lat'] = $geocode->getLatitude();
                         $events['data'][$i]['lng'] = $geocode->getLongitude();
                     }
                     $i++;
                 }
             }
         }
         if (sizeof($events['data']) > 0) {
             $results['data'] = $events['data'];
         }
     } catch (FacebookApiException $e) {
         mapi_report('Cannot download events, try again later.', 'error');
     }
     return $results;
 }
Esempio n. 2
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);
     }
 }
 protected function delete_record()
 {
     if (!$this->permission()) {
         return mapi_report('No permission to edit this content');
     }
     if ($this->id && MValidate::id($this->id)) {
         $record = ORM::for_table('contents')->find_one(intval($this->id));
         if ($record->delete()) {
             $this->wipe_meta();
             $this->wipe_media();
             return true;
         }
     }
     return false;
 }
Esempio n. 4
0
 public function delete()
 {
     if (!$this->permission()) {
         return mapi_report('No permission to edit this category');
     }
     if ($this->id && MValidate::id($this->id)) {
         $category = ORM::for_table('categories')->find_one(intval($this->id));
         if ($category->delete()) {
             return mapi_report_message('Your category was sucessfully deleted.', 'success');
         }
     }
 }