Пример #1
0
 /**
  * Authorizes a peice of uploaded content
  *
  * @version     1.0
  * @since       1.0.0
  * @author      Richard Clifford
  *
  * @param       int     $fid        The file ID
  * @param       bool    $confirm    Confirm with the user that the upload has been authorized
  *
  * @return      bool
  */
 public function authorize($fid, $confirm = false)
 {
     if (is_empty($fid)) {
         return false;
     }
     $objPlugins = Core_Classes_coreObj::getPlugins();
     $objSQL = Core_Classes_coreObj::getDBO();
     $objUser = Core_Classes_coreObj::getUser();
     // Check if the file is already authorized
     $checkAuth = $objSQL->queryBuilder()->select('authorized', 'uid')->from('#__uploads')->where('id', '=', $fid)->build();
     $fileAuth = $objSQL->fetchLine($checkAuth);
     $objPlugins->hook('CMS_AUTHORIZE_UPLOAD');
     // return true if the file is already authorized
     if (isset($fileAuth['authorized']) && $fileAuth['authorized'] == '1') {
         return true;
     }
     // Update the uploads content to be authorized
     $query = $objSQL->queryBuilder()->update('#__uploads')->set(array('authorized' => 1))->where('id', '=', $fid)->build();
     $result = $objSQL->query($query);
     if ($result) {
         $uid = !is_empty($fileAuth['uid']) ? $fileAuth['uid'] : false;
         if ($confirm && $uid) {
             $to = $objUser->get('email', $fileAuth['uid']);
             $from = sprintf('no-reply@', ltrim($_SERVER['SERVER_NAME'], 'www.'));
             $subject = sprintf('Your upload has been authorized - %s', $_SERVER['SERVER_NAME']);
             $message = sprintf('Your upload has now been authorized at %s', $_SERVER['SERVER_NAME']);
             _mailer($to, $from, $subject, $message);
         }
         return true;
     }
     return false;
 }
Пример #2
0
 /**
   //
   //-- Functions
   //
 **/
 public function register(array $userInfo)
 {
     if (is_empty($userInfo)) {
         return false;
     }
     $objSQL = Core_Classes_coreObj::getDBO();
     $userColumnData = $objSQL->fetchColumnData('#__users', 'Field');
     $userExtraColumnData = $objSQL->fetchColumnData('#__users_extras', 'Field');
     $keys = array_keys($settings);
     $userData = $userExtraData = array();
     if (is_empty($keys)) {
         return false;
     }
     // Loop through the settings keys
     foreach ($keys as $key) {
         // Check if the keys belong to users_extras table or users_extras table
         if (in_array($key, $userColumnData)) {
             $userData[$key] = sprintf(getTokenType($settings[$key]), $settings[$key]);
         }
         if (in_array($key, $userExtraColumnData)) {
             $userExtraData[$key] = sprintf(getTokenType($settings[$key]), $settings[$key]);
         }
     }
     // Check if the userData is empty
     // If it isn't then update the table
     if (!is_empty($userData)) {
         $insert = $objSQL->queryBuilder()->insertInto('#__users')->set($userData)->build();
         $userInsertResult = $objSQL->query($insert);
         if (!$userInsertResult) {
             trigger_error('Could not update the users table');
             return false;
         }
     }
     // Check if the userExtraData is empty
     // If it isn't then update the table
     if (!is_empty($userExtraData)) {
         $insertExtras = $objSQL->queryBuilder()->insertInto('#__users_extras')->set($userExtraData)->build();
         $userExtrasInsertResult = $objSQL->query($insertExtras);
         if (!$userExtrasInsertResult) {
             trigger_error('Could not update the users extras table');
             return false;
         }
     }
     // Send Confirmation mail
     $siteName = $this->config('site', 'title');
     // Needs to be updated correctly
     $siteEmail = sprintf('no-reply@%s', $this->config('site', 'url'));
     $message = sprintf("Dear %s,\n\r\n            Thank you for registering for %s\n\r", $userData['username'], $siteName);
     $mail = _mailer($userData['email'], $siteEmail, sprintf('Registration Details From %s', $siteName), $message);
     return $mail;
 }