Exemplo n.º 1
0
 /**
  * @param DleUsers $objDleUsers The DB ORM object to process
  */
 protected function process_object($objDleUsers)
 {
     // wp: ID,      user_login, user_nicename, user_email, user_registered,           display_name
     // dl: user_id, name,       name,          email,      FROM_UNIXTIME( reg_date ), fullname
     $strEmail = $objDleUsers->Email;
     if ($strEmail && strlen($strEmail)) {
         // check if already copied
         if (!WpUsers::QueryCount(QQ::Equal(QQN::WpUsers()->UserEmail, $strEmail))) {
             $objWpUsers = new WpUsers();
             $objWpUsers->Initialize();
             // set defaults
             $objWpUsers->UserLogin = $objDleUsers->Name;
             $objWpUsers->UserNicename = $objDleUsers->Name;
             $objWpUsers->UserEmail = $objDleUsers->Email;
             $objWpUsers->UserRegistered = QDateTime::FromTimestamp(intval($objDleUsers->RegDate));
             $objWpUsers->DisplayName = $objDleUsers->Fullname;
             $objWpUsers->UserPass = '';
             $objWpUsers->UserUrl = '';
             $objWpUsers->UserActivationKey = '';
             $objWpUsers->UserStatus = 0;
             $objWpUsers->Save();
             $this->intUserCount++;
         }
     }
 }
Exemplo n.º 2
0
 /**
  * @return WpUsers The Wordpress user for this DLE post author.
  */
 public function LoadWpUser()
 {
     $objDleUsers = DleUsers::LoadByName($this->Autor);
     if (!$objDleUsers) {
         return null;
     }
     return WpUsers::QuerySingle(QQ::Equal(QQN::WpUsers()->UserEmail, $objDleUsers->Email), QQ::Clause(QQ::LimitInfo(1)));
 }
Exemplo n.º 3
0
 /**
  * @return WpUsers|null The Wordpress user for this DLE comment author.
  */
 public function LoadWpUsers()
 {
     $objDleUsers = $this->User;
     if (!$objDleUsers) {
         return WpUsers::QuerySingle(QQ::Equal(QQN::WpUsers()->UserEmail, $this->Email), QQ::Clause(QQ::LimitInfo(1)));
     }
     return $objDleUsers->LoadWpUsers();
 }
Exemplo n.º 4
0
 public static function wp_create_user($user_id, $user_name, $brought_by)
 {
     # Update Wp Db
     $u = new WpUsers();
     $u->ID = $user_id;
     $u->user_nicename = $user_name;
     $u->display_name = $user_name;
     $u->save();
     # Insert into mfr_db
     $sql = 'INSERT INTO `mfr_users` (`id`, `date_created`, `last_updated`, `level`, `coach`, `coaching_status`, `last_notification` , `last_chat_message` , `brought_by`) VALUES (?,?,?,?,\'0\',\'0\',\'0\',\'0\', ?)';
     $sql_time = time();
     $sql_level = '1';
     $stmt = \Mariana\Framework\Database::getConnection()->prepare($sql);
     $stmt->bindParam(1, $user_id);
     $stmt->bindParam(2, $sql_time);
     $stmt->bindParam(3, $sql_time);
     $stmt->bindParam(4, $sql_level);
     $stmt->bindParam(5, $brought_by);
     if ($stmt->execute()) {
         #creating the user files;
         $path = USER_PATH . DS . $user_id;
         if (mkdir($path, 0777)) {
             # Create notification files
             $file = fopen(USER_PATH . DS . $user_id . DS . "notify.txt", "w");
             fwrite($file, '');
             fclose($file);
             # Create user upload directory
             $path = UPLOAD_PATH . DS . $user_id;
             if (mkdir($path, 0777)) {
                 return true;
             }
         }
         return false;
     }
     return false;
 }
Exemplo n.º 5
0
 /**
  * Process the task.
  */
 public function execute()
 {
     try {
         WpUsers::GetDatabase()->TransactionBegin();
         $intTimeBegin = time();
         do {
             $intTime = time();
             if (self::checkBreak($intTimeBegin)) {
                 break;
             }
             $objDleObjectArray = $this->get_objects_array($this->intOffset);
             if (!$objDleObjectArray) {
                 break;
             }
             foreach ($objDleObjectArray as $objDleObject) {
                 if (self::checkBreak($intTimeBegin)) {
                     break;
                 }
                 $this->process_object($objDleObject);
                 $this->intOffset++;
             }
             if (self::checkBreak($intTimeBegin)) {
                 break;
             }
         } while (true);
         $this->intTimeElapsed += time() - $intTimeBegin;
         WpUsers::GetDatabase()->TransactionCommit();
     } catch (QDatabaseExceptionBase $ex) {
         WpUsers::GetDatabase()->TransactionRollBack();
         throw $ex;
     } catch (QCallerException $ex) {
         WpUsers::GetDatabase()->TransactionRollBack();
         $ex->IncrementOffset();
         throw $ex;
     } catch (Exception $ex) {
         WpUsers::GetDatabase()->TransactionRollBack();
         throw $ex;
     }
 }
 /**
  * @param DleStatic $objDleStatic The DB ORM object to process
  */
 protected function process_object($objDleStatic)
 {
     $objWpPosts0 = $objDleStatic->LoadWpPost();
     if ($objWpPosts0) {
         return;
     }
     $objWpUsers = WpUsers::LoadFirst();
     if (!$objWpUsers) {
         return;
     }
     $objWpPosts = new WpPosts();
     $objWpPosts->Initialize();
     // set defaults
     $objWpPosts->PostAuthor = $objWpUsers->Id;
     $objWpPosts->PostDate = $objDleStatic->Date;
     $objWpPosts->PostModified = $objDleStatic->Date;
     $objWpPosts->PostDateGmt = $objDleStatic->Date;
     $objWpPosts->PostModifiedGmt = $objDleStatic->Date;
     $objWpPosts->PostContent = str_replace('{ACCEPT-DECLINE}', '', str_replace('\\»', '»', str_replace('\\"', '"', $objDleStatic->Template)));
     $objWpPosts->PostContentFiltered = "";
     $objWpPosts->PostParent = 0;
     $objWpPosts->PostTitle = $objDleStatic->Descr;
     $objWpPosts->PostExcerpt = str_replace('\\»', '»', str_replace('\\"', '"', $objDleStatic->Metadescr));
     $objWpPosts->CommentStatus = "open";
     $objWpPosts->PingStatus = "open";
     $objWpPosts->PostStatus = "publish";
     $objWpPosts->PostPassword = "";
     $objWpPosts->PostName = $objDleStatic->Name;
     $objWpPosts->ToPing = "";
     $objWpPosts->Pinged = "";
     $objWpPosts->Guid = "";
     $objWpPosts->MenuOrder = 0;
     $objWpPosts->PostType = "page";
     $objWpPosts->PostMimeType = "";
     $objWpPosts->CommentCount = 0;
     $objWpPosts->Save();
     $this->intPostCount++;
 }
Exemplo n.º 7
0
 public static function GetSoapArrayFromArray($objArray)
 {
     if (!$objArray) {
         return null;
     }
     $objArrayToReturn = array();
     foreach ($objArray as $objObject) {
         array_push($objArrayToReturn, WpUsers::GetSoapObjectFromObject($objObject, true));
     }
     return unserialize(serialize($objArrayToReturn));
 }
Exemplo n.º 8
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objUser) {
         $objObject->objUser = WpUsers::GetSoapObjectFromObject($objObject->objUser, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intUserId = null;
         }
     }
     return $objObject;
 }
Exemplo n.º 9
0
 /**
  * @return WpUsers The Wordpress user for this DLE user.
  */
 public function LoadWpUsers()
 {
     return WpUsers::QuerySingle(QQ::Equal(QQN::WpUsers()->UserEmail, $this->Email), QQ::Clause(QQ::LimitInfo(1)));
 }
Exemplo n.º 10
0
 public function signup($params = array())
 {
     # Requirements
     $this->load();
     $this->status['status'] = 'fail';
     # Params
     $user_login = $params['username'];
     $user_name = $params['name'];
     $user_email = $params['email'];
     $user_password = $params['password'];
     $user_password_2 = $params['password_confirm'];
     $brought_by = $params['code'];
     $brought_by = str_replace('#mfr_', '', strtolower($brought_by));
     # Validation
     if (!Session::csrf($params['mariana-csrf'])) {
         $this->status['errors'] = array(Lang::get('csrf-check-fail'));
         $this->return_json($this->status);
         return header('HTTP/1.0 200 OK');
     }
     $inputs = array('username' => array('name' => 'username', 'required' => true, 'alfanum' => true), 'password' => array('name' => 'password', 'required' => true, 'alfanum' => true, 'min' => 3, 'max' => 32), 'password_confirm' => array('name' => 'password_confirm', 'matches' => 'password', 'required' => true), 'email' => array('required' => true, 'email' => true));
     if (Validation::check($inputs) === false) {
         $this->status['errors'] = Framework\Session\Flash::showMessages();
         $this->return_json($this->status);
         return header('HTTP/1.0 200 OK');
     }
     $check_if_username_exists = WpUsers::wp_unique_user($user_login, $user_email);
     if ($check_if_username_exists) {
         $this->status['errors'] = $check_if_username_exists;
         $this->return_json($this->status);
         return header('HTTP/1.0 200 OK');
     }
     # Create entry on both databases
     $user_id = wp_create_user($user_login, $user_password, $user_email);
     MfrUsers::wp_create_user($user_id, $user_name, $brought_by);
     # Notify
     wp_new_user_notification($user_id, $user_password);
     # Sign the user in
     $params = array();
     $params['username'] = $user_login;
     $params['password'] = $user_password;
     $this->login($params);
     $this->return_json($this->status);
     # Forcing code 200 - Dunno why but keeps failing on this specific function
     return header('HTTP/1.0 200 OK');
 }
Exemplo n.º 11
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objCommentPostIDObject) {
         $objObject->objCommentPostIDObject = WpPosts::GetSoapObjectFromObject($objObject->objCommentPostIDObject, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intCommentPostID = null;
         }
     }
     if ($objObject->dttCommentDate) {
         $objObject->dttCommentDate = $objObject->dttCommentDate->qFormat(QDateTime::FormatSoap);
     }
     if ($objObject->dttCommentDateGmt) {
         $objObject->dttCommentDateGmt = $objObject->dttCommentDateGmt->qFormat(QDateTime::FormatSoap);
     }
     if ($objObject->objCommentParentObject) {
         $objObject->objCommentParentObject = WpComments::GetSoapObjectFromObject($objObject->objCommentParentObject, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intCommentParent = null;
         }
     }
     if ($objObject->objUser) {
         $objObject->objUser = WpUsers::GetSoapObjectFromObject($objObject->objUser, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intUserId = null;
         }
     }
     return $objObject;
 }
Exemplo n.º 12
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objPostAuthorObject) {
         $objObject->objPostAuthorObject = WpUsers::GetSoapObjectFromObject($objObject->objPostAuthorObject, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intPostAuthor = null;
         }
     }
     if ($objObject->dttPostDate) {
         $objObject->dttPostDate = $objObject->dttPostDate->qFormat(QDateTime::FormatSoap);
     }
     if ($objObject->dttPostDateGmt) {
         $objObject->dttPostDateGmt = $objObject->dttPostDateGmt->qFormat(QDateTime::FormatSoap);
     }
     if ($objObject->dttPostModified) {
         $objObject->dttPostModified = $objObject->dttPostModified->qFormat(QDateTime::FormatSoap);
     }
     if ($objObject->dttPostModifiedGmt) {
         $objObject->dttPostModifiedGmt = $objObject->dttPostModifiedGmt->qFormat(QDateTime::FormatSoap);
     }
     if ($objObject->objPostParentObject) {
         $objObject->objPostParentObject = WpPosts::GetSoapObjectFromObject($objObject->objPostParentObject, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intPostParent = null;
         }
     }
     return $objObject;
 }
Exemplo n.º 13
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objPollipQidObject) {
         $objObject->objPollipQidObject = WpPollsq::GetSoapObjectFromObject($objObject->objPollipQidObject, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->strPollipQid = null;
         }
     }
     if ($objObject->objPollipAidObject) {
         $objObject->objPollipAidObject = WpPollsa::GetSoapObjectFromObject($objObject->objPollipAidObject, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->strPollipAid = null;
         }
     }
     if ($objObject->objPollipUseridObject) {
         $objObject->objPollipUseridObject = WpUsers::GetSoapObjectFromObject($objObject->objPollipUseridObject, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intPollipUserid = null;
         }
     }
     return $objObject;
 }
Exemplo n.º 14
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objPost) {
         $objObject->objPost = WpPosts::GetSoapObjectFromObject($objObject->objPost, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intPostId = null;
         }
     }
     if ($objObject->dttDateTime) {
         $objObject->dttDateTime = $objObject->dttDateTime->qFormat(QDateTime::FormatSoap);
     }
     if ($objObject->objUser) {
         $objObject->objUser = WpUsers::GetSoapObjectFromObject($objObject->objUser, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intUserId = null;
         }
     }
     return $objObject;
 }