示例#1
0
 function update041()
 {
     $this->mLog->addReport(_AD_LEGACY_MESSAGE_UPDATE_STARTED);
     //Add Table
     $sqlfileInfo = $this->_mTargetXoopsModule->getInfo('sqlfile');
     $dirname = $this->_mTargetXoopsModule->getVar('dirname');
     $sqlfile = $sqlfileInfo[XOOPS_DB_TYPE];
     $sqlfilepath = XOOPS_MODULE_PATH . '/' . $dirname . '/' . $sqlfile;
     require_once XOOPS_MODULE_PATH . '/legacy/admin/class/Legacy_SQLScanner.class.php';
     $scanner = new Legacy_SQLScanner();
     $scanner->setDB_PREFIX(XOOPS_DB_PREFIX);
     $scanner->setDirname($this->_mTargetXoopsModule->get('dirname'));
     if (!$scanner->loadFile($sqlfilepath)) {
         $this->mLog->addError(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_SQL_FILE_NOT_FOUND, $sqlfile));
         return false;
     }
     $scanner->parse();
     $sqls = $scanner->getSQL();
     $root = XCube_Root::getSingleton();
     $db = $root->mController->getDB();
     foreach ($sqls as $sql) {
         if (strpos($sql, '_message_users') !== false) {
             if (!$db->query($sql)) {
                 $this->mLog->addError($db->error());
                 return false;
             }
         }
     }
     $this->mLog->addReport(_AD_LEGACY_MESSAGE_DATABASE_SETUP_FINISHED);
     //add table
     $this->updatemain();
     return true;
 }
示例#2
0
 public static function getNewMessage(&$arrays)
 {
     $root = XCube_Root::getSingleton();
     if ($root->mContext->mUser->isInRole('Site.RegisteredUser')) {
         $uid = $root->mContext->mXoopsUser->get('uid');
         $modHand = xoops_getmodulehandler('inbox', 'message');
         $num = $modHand->getCountUnreadByFromUid($uid);
         if ($num > 0) {
             $root->mLanguageManager->loadModuleMessageCatalog('message');
             $arrays[] = array('url' => XOOPS_MODULE_URL . '/message/index.php', 'title' => XCube_Utils::formatString(_MD_MESSAGE_NEWMESSAGE, $num));
         }
     }
 }
 function executeViewIndex(&$controller, &$xoopsUser, &$render)
 {
     //
     // Because this action's template uses USER message catalog, load it.
     //
     $root =& $controller->mRoot;
     $config_handler =& xoops_gethandler('config');
     $moduleConfigUser =& $config_handler->getConfigsByDirname('user');
     if ($moduleConfigUser['use_ssl'] == 1 && !empty($_POST[$moduleConfigUser['sslpost_name']])) {
         session_id($_POST[$moduleConfigUser['sslpost_name']]);
     }
     $render->setTemplateName("legacy_misc_ssllogin.html");
     $render->setAttribute("message", XCube_Utils::formatString(_MD_LEGACY_MESSAGE_LOGIN_SUCCESS, $xoopsUser->get('uname')));
 }
示例#4
0
 function validateBmodule()
 {
     $bmodule = $this->get('bmodule');
     if (!count($bmodule)) {
         $this->addErrorMessage(_AD_LEGACY_ERROR_BMODULE);
     } else {
         $handler =& xoops_gethandler('module');
         foreach ($this->get('bmodule') as $mid) {
             $module =& $handler->get($mid);
             if ($mid != -1 && $mid != 0 && !is_object($module)) {
                 $this->addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_OBJECTEXIST, _AD_LEGACY_LANG_BMODULE));
             }
         }
     }
 }
 function preBlockFilter()
 {
     if (LEGACY_INSTALLERCHECKER_ACTIVE == true && is_dir(XOOPS_ROOT_PATH . "/install")) {
         $root =& XCube_Root::getSingleton();
         $root->mLanguageManager->loadModuleMessageCatalog('legacy');
         $xoopsConfig = $root->mContext->mXoopsConfig;
         require_once XOOPS_ROOT_PATH . '/class/template.php';
         $xoopsTpl = new XoopsTpl();
         $xoopsTpl->assign(array('xoops_sitename' => htmlspecialchars($xoopsConfig['sitename']), 'xoops_themecss' => xoops_getcss(), 'xoops_imageurl' => XOOPS_THEME_URL . '/' . $xoopsConfig['theme_set'] . '/', 'lang_message_confirm' => XCube_Utils::formatMessage(_MD_LEGACY_MESSAGE_INSTALL_COMPLETE_CONFIRM, XOOPS_ROOT_PATH . "/install"), 'lang_message_warning' => XCube_Utils::formatMessage(_MD_LEGACY_MESSAGE_INSTALL_COMPLETE_WARNING, XOOPS_ROOT_PATH . "/install")));
         $xoopsTpl->compile_check = true;
         // @todo filebase template with absolute file path
         $xoopsTpl->display(XOOPS_ROOT_PATH . '/modules/legacy/templates/legacy_install_completed.html');
         exit;
     }
 }
 function validate()
 {
     parent::validate();
     //
     // If htmlbanner is clicked, htmlbanner is requreid.
     //
     if ($this->get('htmlbanner')) {
         if (strlen($this->get('htmlcode')) == 0) {
             $this->addErrorMessage(XCube_Utils::formatString(_AD_LEGACYRENDER_ERROR_REQUIRED, _AD_LEGACYRENDER_LANG_HTMLCODE));
         }
     } else {
         if (strlen($this->get('imageurl')) == 0) {
             $this->addErrorMessage(XCube_Utils::formatString(_AD_LEGACYRENDER_ERROR_REQUIRED, _AD_LEGACYRENDER_LANG_IMAGEURL));
         }
         if (strlen($this->get('clickurl')) == 0) {
             $this->addErrorMessage(XCube_Utils::formatString(_AD_LEGACYRENDER_ERROR_REQUIRED, _AD_LEGACYRENDER_LANG_CLICKURL));
         }
     }
 }
 function uninstallPreferenceByOrder($order, &$module, &$log)
 {
     $handler =& xoops_gethandler('config');
     $criteria = new CriteriaCompo();
     $criteria->add(new Criteria('conf_modid', $module->get('mid')));
     $criteria->add(new Criteria('conf_catid', 0));
     $criteria->add(new Criteria('conf_order', $order));
     $configArr =& $handler->getConfigs($criteria);
     foreach (array_keys($configArr) as $idx) {
         if ($handler->deleteConfig($configArr[$idx])) {
             $log->addReport(XCube_Utils::formatMessage("Delete preference '{0}'.", $configArr[$idx]->get('conf_name')));
         } else {
             $log->addError(XCube_Utils::formatMessage("Could not delete preference '{0}'.", $configArr[$idx]->get('conf_name')));
         }
     }
 }
 function _saveSmilesImages(&$smilesimages)
 {
     if (count($smilesimages) == 0) {
         return true;
     }
     $smileshandler =& xoops_getmodulehandler('smiles');
     for ($i = 0; $i < count($smilesimages); $i++) {
         $ext_pos = strrpos($smilesimages[$i]['name'], '.');
         if ($ext_pos === false) {
             continue;
         }
         $ext = strtolower(substr($smilesimages[$i]['name'], $ext_pos + 1));
         if (empty($this->mAllowedExts[$ext])) {
             continue;
         }
         $file_name = substr($smilesimages[$i]['name'], 0, $ext_pos);
         $save_file_name = uniqid('smil') . '.' . $ext;
         $filehandle = fopen(XOOPS_UPLOAD_PATH . '/' . $save_file_name, "w");
         if (!$filehandle) {
             $this->_addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_COULD_NOT_SAVE_SMILES_FILE, $file_name));
             continue;
         }
         if (!@fwrite($filehandle, $smilesimages[$i]['content'])) {
             $this->_addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_COULD_NOT_SAVE_SMILES_FILE, $file_name));
             @fclose($filehandle);
             continue;
         }
         @fclose($filehandle);
         $smiles =& $smileshandler->create();
         $smiles->set('code', $file_name);
         $smiles->set('emotion', $file_name);
         $smiles->set('smile_url', $save_file_name);
         $smiles->set('display', 1);
         if (!$smileshandler->insert($smiles)) {
             $this->_addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_COULD_NOT_SAVE_SMILES_FILE, $file_name));
         }
         unset($smiles);
     }
     return true;
 }
示例#9
0
//-- for cache by group
$menu_cache_file = XOOPS_TRUST_PATH . '/cache/theme_' . $theme_name . '_menus_' . SITE_SALT;
// PM
if (is_object(@$xoopsUser)) {
    if (defined('XOOPS_CUBE_LEGACY')) {
        $url = null;
        $root = XCube_Root::getSingleton();
        $service =& $root->mServiceManager->getService('privateMessage');
        if ($service != null) {
            $client =& $root->mServiceManager->createClient($service);
            $url = $client->call('getPmInboxUrl', array('uid' => $root->mContext->mXoopsUser->get('uid')));
            if ($url != null) {
                $xugj_pm_new_count = $client->call('getCountUnreadPM', array('uid' => $root->mContext->mXoopsUser->get('uid')));
                if (intval($xugj_pm_new_count) > 0) {
                    $root->mLanguageManager->loadModuleMessageCatalog('message');
                    $xugj_pm_new_message = XCube_Utils::formatString(_MD_MESSAGE_NEWMESSAGE, $xugj_pm_new_count);
                    $this->assign('xugj_pm_new_message', $xugj_pm_new_message . "<br/><a href='" . $url . "'>" . _MD_MESSAGE_TEMPLATE15 . "</a>");
                }
                $this->assign('xugj_pm_new_count', intval($xugj_pm_new_count));
                $this->assign('xugj_pm_inbox_url', $url);
            }
        } else {
            $pm_handler =& xoops_gethandler('privmessage', true);
            if (is_object($pm_handler)) {
                $criteria = new CriteriaCompo(new Criteria('read_msg', 0));
                $criteria->add(new Criteria('to_userid', $root->mContext->mXoopsUser->get('uid')));
                $this->assign('pm', array(new_messages => $pm_handler->getCount($criteria)));
            }
        }
    } else {
        $pm_handler =& xoops_gethandler('privmessage');
示例#10
0
 /**
  * Check the login request through delegates, and set XoopsObject to member
  * property if the login is success.
  * 
  * @access public
  */
 function checkLogin()
 {
     if (!is_object($this->mRoot->mContext->mXoopsUser)) {
         $this->mCheckLogin->call(new XCube_Ref($this->mRoot->mContext->mXoopsUser));
         $this->mRoot->mLanguageManager->loadModuleMessageCatalog('legacy');
         if (is_object($this->mRoot->mContext->mXoopsUser)) {
             // If the current user doesn't bring to any groups, kick out him for XCL's security.
             $t_groups =& $this->mRoot->mContext->mXoopsUser->getGroups();
             if (!is_array($t_groups)) {
                 // exception
                 $this->logout();
                 return;
             } else {
                 if (count($t_groups) == 0) {
                     // exception, too
                     $this->logout();
                     return;
                 }
             }
             // RMV-NOTIFY
             // Perform some maintenance of notification records
             $notification_handler =& xoops_gethandler('notification');
             $notification_handler->doLoginMaintenance($this->mRoot->mContext->mXoopsUser->get('uid'));
             XCube_DelegateUtils::call("Site.CheckLogin.Success", new XCube_Ref($this->mRoot->mContext->mXoopsUser));
             //
             // Fall back process for login success.
             //
             $url = XOOPS_URL;
             if (!empty($_POST['xoops_redirect']) && !strpos(xoops_getrequest('xoops_redirect'), 'register')) {
                 $parsed = parse_url(XOOPS_URL);
                 $url = isset($parsed['scheme']) ? $parsed['scheme'] . '://' : 'http://';
                 if (isset($parsed['host'])) {
                     $url .= isset($parsed['port']) ? $parsed['host'] . ':' . $parsed['port'] . trim(xoops_getrequest('xoops_redirect')) : $parsed['host'] . trim(xoops_getrequest('xoops_redirect'));
                 } else {
                     $url .= xoops_getenv('HTTP_HOST') . trim(xoops_getrequest('xoops_redirect'));
                 }
             }
             $this->executeRedirect($url, 1, XCube_Utils::formatMessage(_MD_LEGACY_MESSAGE_LOGIN_SUCCESS, $this->mRoot->mContext->mXoopsUser->get('uname')));
         } else {
             XCube_DelegateUtils::call("Site.CheckLogin.Fail", new XCube_Ref($this->mRoot->mContext->mXoopsUser));
             //
             // Fall back process for login fail.
             //
             $this->executeRedirect(XOOPS_URL . "/user.php", 1, _MD_LEGACY_ERROR_INCORRECTLOGIN);
         }
     } else {
         $this->executeForward(XOOPS_URL . '/');
     }
 }
示例#11
0
 /**
  * @deprecated XCube 1.0 will remove this method.
  * @see XCube_Utils::formatString()
  */
 function formatMessage()
 {
     $arr = func_get_args();
     if (count($arr) == 0) {
         return null;
     } else {
         if (count($arr) == 1) {
             return XCube_Utils::formatString($arr[0]);
         } else {
             if (count($arr) > 1) {
                 $vals = $arr;
                 array_shift($vals);
                 return XCube_Utils::formatString($arr[0], $vals);
             }
         }
     }
 }
示例#12
0
 function validate()
 {
     parent::validate();
     $handler =& xoops_getmodulehandler('imagecategory', 'legacy');
     $category =& $handler->get($this->get('imgcat_id'));
     $formFile = $this->get('image_name');
     if ($formFile != null && is_object($category)) {
         //
         // Imagefile width & height check.
         //
         if ($formFile->getWidth() > $category->get('imgcat_maxwidth') || $formFile->getHeight() > $category->get('imgcat_maxheight')) {
             $this->addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_IMG_SIZE, $category->get('imgcat_maxwidth'), $category->get('imgcat_maxheight')));
         }
         //
         // Check file size
         //
         if ($formFile->getFilesize() > $category->get('imgcat_maxsize')) {
             $this->addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_IMG_FILESIZE, $category->get('imgcat_maxsize')));
         }
     }
 }
示例#13
0
 function validateSmile_url()
 {
     if ($this->_mIsNew && $this->get('smile_url') == null) {
         $this->addErrorMessage(XCube_Utils::formatMessage(_MD_LEGACY_ERROR_REQUIRED, _AD_LEGACY_LANG_SMILE_URL));
     }
 }
示例#14
0
 function _processReport()
 {
     if (!$this->mLog->hasError()) {
         $this->mLog->add(XCube_Utils::formatMessage(_AD_LEGACY_MESSAGE_UPDATING_MODULE_SUCCESSFUL, $this->_mCurrentXoopsModule->get('name')));
     } else {
         $this->mLog->addError(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_UPDATING_MODULE_FAILURE, $this->_mCurrentXoopsModule->get('name')));
     }
 }
 /**
  * リダイレクトする
  * @param XoopsUser $xoopsUser
  */
 public function redirect(XoopsUser $xoopsUser)
 {
     $url = $this->_getRedirectURL();
     $message = XCube_Utils::formatMessage(_MD_LEGACY_MESSAGE_LOGIN_SUCCESS, $xoopsUser->get('uname'));
     $this->mRoot->mController->executeRedirect($url, 1, $message);
 }
示例#16
0
 /**
  * Set a config value
  * 
  * @param	mixed   &$value Value
  * @param	bool    $force_slash
  */
 function setConfValueForInput(&$value, $force_slash = false)
 {
     switch ($this->getVar('conf_valuetype')) {
         case 'array':
             if (!is_array($value)) {
                 $value = explode('|', trim($value));
             }
             $this->setVar('conf_value', serialize($value), $force_slash);
             break;
         case 'text':
             $this->setVar('conf_value', trim($value), $force_slash);
             break;
         case 'encrypt':
             $this->setVar('conf_value', XCube_Utils::encrypt(trim($value)), $force_slash);
             break;
         default:
             $this->setVar('conf_value', $value, $force_slash);
             break;
     }
 }
示例#17
0
 function _setUniqueToGroupUserLink()
 {
     $root =& XCube_Root::getSingleton();
     $db =& $root->mController->getDB();
     $table = $db->prefix('groups_users_link');
     // Delete duplicate data.
     $sql = 'SELECT `uid`,`groupid`,COUNT(*) AS c FROM `' . $table . '` GROUP BY `uid`,`groupid` HAVING `c` > 1';
     if ($res = $db->query($sql)) {
         while ($row = $db->fetchArray($res)) {
             $sql = sprintf('DELETE FROM `%s` WHERE `uid` = %d AND `groupid` = %d ORDER BY `linkid` DESC', $table, $row['uid'], $row['groupid']);
             if (!$db->query($sql, $row['c'] - 1)) {
                 $this->mLog->addError(XCube_Utils::formatString(_AD_LEGACY_ERROR_COULD_NOT_DELETE_DUPLICATE_DATA, $table));
                 return;
             }
         }
     }
     // Set unique key.
     $sql = 'ALTER TABLE `' . $table . '` DROP INDEX `groupid_uid`';
     $db->query($sql);
     // ignore sql errors
     $sql = 'ALTER TABLE `' . $table . '` ADD UNIQUE `uid_groupid` (`uid`,`groupid`)';
     if ($db->query($sql)) {
         $this->mLog->addReport(XCube_Utils::formatString(_AD_LEGACY_MESSAGE_SET_UNIQUE_KEY_SUCCESSFUL, $table));
     } else {
         $this->mLog->addError(XCube_Utils::formatString(_AD_LEGACY_ERROR_COULD_NOT_SET_UNIQUE_KEY, $table));
     }
 }
示例#18
0
 function validateRank()
 {
     $t_rank = $this->get('rank');
     if ($t_rank > 0) {
         $handler =& xoops_getmodulehandler('ranks', 'user');
         $rank =& $handler->get($t_rank);
         if (!is_object($rank)) {
             $this->addErrorMessage(XCube_Utils::formatString(_MD_USER_ERROR_INJURY, _AD_USER_LANG_RANK));
         } elseif ($rank->get('rank_special') != 1) {
             $this->addErrorMessage(XCube_Utils::formatString(_MD_USER_ERROR_INJURY, _AD_USER_LANG_RANK));
         }
     }
 }
 function _saveTargetImages(&$targetimages, $t_imgcat_id)
 {
     if (count($targetimages) == 0) {
         return true;
     }
     $imgcathandler =& xoops_getmodulehandler('imagecategory', 'legacy');
     $t_category =& $imgcathandler->get($t_imgcat_id);
     $t_category_type = $t_category->get('imgcat_storetype');
     $imagehandler =& xoops_getmodulehandler('image');
     if (strtolower($t_category_type) == "file") {
         for ($i = 0; $i < count($targetimages); $i++) {
             $ext_pos = strrpos($targetimages[$i]['name'], '.');
             if ($ext_pos === false) {
                 continue;
             }
             $ext = strtolower(substr($targetimages[$i]['name'], $ext_pos + 1));
             if (empty($this->mAllowedExts[$ext])) {
                 continue;
             }
             $file_name = substr($targetimages[$i]['name'], 0, $ext_pos);
             $save_file_name = uniqid('img') . '.' . $ext;
             $filehandle = fopen(XOOPS_UPLOAD_PATH . '/' . $save_file_name, "w");
             if (!$filehandle) {
                 $this->_addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_COULD_NOT_SAVE_IMAGE_FILE, $file_name));
                 continue;
             }
             if (!@fwrite($filehandle, $targetimages[$i]['content'])) {
                 $this->_addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_COULD_NOT_SAVE_IMAGE_FILE, $file_name));
                 @fclose($filehandle);
                 continue;
             }
             @fclose($filehandle);
             $image =& $imagehandler->create();
             $image->set('image_nicename', $file_name);
             $image->set('image_name', $save_file_name);
             $image->set('image_mimetype', $this->mAllowedExts[$ext]);
             $image->set('image_display', 1);
             $image->set('imgcat_id', $t_imgcat_id);
             if (!$imagehandler->insert($image)) {
                 $this->_addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_COULD_NOT_SAVE_IMAGE_FILE, $file_name));
             }
             unset($image);
         }
         //end of for
     } elseif (strtolower($t_category_type) == "db") {
         for ($i = 0; $i < count($targetimages); $i++) {
             $ext_pos = strrpos($targetimages[$i]['name'], '.');
             if ($ext_pos === false) {
                 continue;
             }
             $ext = strtolower(substr($targetimages[$i]['name'], $ext_pos + 1));
             if (empty($this->mAllowedExts[$ext])) {
                 continue;
             }
             $file_name = substr($targetimages[$i]['name'], 0, $ext_pos);
             $save_file_name = uniqid('img') . '.' . $ext;
             //
             $image =& $imagehandler->create();
             $image->set('image_nicename', $file_name);
             $image->set('image_name', $save_file_name);
             $image->set('image_mimetype', $this->mAllowedExts[$ext]);
             $image->set('image_display', 1);
             $image->set('imgcat_id', $t_imgcat_id);
             $image->loadImageBody();
             if (!is_object($image->mImageBody)) {
                 $image->mImageBody =& $image->createImageBody();
             }
             $image->mImageBody->set('image_body', $targetimages[$i]['content']);
             if (!$imagehandler->insert($image)) {
                 $this->_addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_COULD_NOT_SAVE_IMAGE_FILE, $file_name));
             }
             unset($image);
         }
         //end of for
     }
     //end of elseif
     return true;
 }
示例#20
0
 /**
  * updateConfigOrderByInfo
  * 
  * @param   Legacy_PreferenceInformation  &$info
  * @param   XoopsModule  &$module
  * @param   Legacy_ModuleInstallLog  &$log
  * 
  * @return  bool
  **/
 public static function updateConfigOrderByInfo(&$info, &$module, &$log)
 {
     $configHandler =& Leimg_Utils::getXoopsHandler('config');
     $cri = new CriteriaCompo();
     $cri->add(new Criteria('conf_modid', $module->get('mid')));
     $cri->add(new Criteria('conf_catid', 0));
     $cri->add(new Criteria('conf_name', $info->mName));
     $configs =& $configHandler->getConfigs($cri);
     if (!(count($configs) > 0 && is_object($configs[0]))) {
         $log->addError(_MI_LEIMG_INSTALL_ERROR_CONFIG_NOT_FOUND);
         return false;
     }
     $config =& $configs[0];
     $config->set('conf_order', $info->mOrder);
     if (!$configHandler->insertConfig($config)) {
         $log->addError(XCube_Utils::formatString(_MI_LEIMG_INSTALL_ERROR_CONFIG_UPDATED, $config->get('conf_name')));
         return false;
     }
     return true;
 }
示例#21
0
 /**
  * Get configs from a certain category
  * 
  * @param	int $category   ID of a category
  * @param	int $module     ID of a module
  * 
  * @return	array   array of {@link XoopsConfig}s 
  * @todo This method keeps cache for categories. This may be problem...
  */
 function &getConfigsByCat($category, $module = 0)
 {
     static $_cachedConfigs = array();
     if (!empty($_cachedConfigs[$module][$category])) {
         return $_cachedConfigs[$module][$category];
     } else {
         $ret = array();
         $criteria = new CriteriaCompo(new Criteria('conf_modid', (int) $module));
         if (!empty($category)) {
             $criteria->add(new Criteria('conf_catid', (int) $category));
         }
         // get config values
         $configs = array();
         $db = $this->_cHandler->db;
         $result = $db->query('SELECT conf_name,conf_value,conf_valuetype FROM ' . $db->prefix('config') . ' ' . $criteria->renderWhere() . ' ORDER BY conf_order ASC');
         if ($result) {
             while (list($name, $value, $type) = $db->fetchRow($result)) {
                 switch ($type) {
                     case 'array':
                         $ret[$name] = unserialize($value);
                         break;
                     case 'encrypt':
                         $ret[$name] = XCube_Utils::decrypt($value);
                         break;
                     default:
                         $ret[$name] = $value;
                 }
             }
             $_cachedConfigs[$module][$category] =& $ret;
         }
         return $ret;
     }
 }
示例#22
0
 private function getMailBody($body = 0)
 {
     $tpl = new Smarty();
     $tpl->_canUpdateFromFile = true;
     $tpl->compile_check = true;
     $tpl->template_dir = _MY_MODULE_PATH . 'language/' . $this->root->mLanguageManager->mLanguageName . '/';
     $tpl->cache_dir = XOOPS_CACHE_PATH;
     $tpl->compile_dir = XOOPS_COMPILE_PATH;
     $tpl->assign('sitename', $this->root->mContext->mXoopsConfig['sitename']);
     $tpl->assign('uname', $this->root->mContext->mXoopsUser->get('uname'));
     if ($body == 1) {
         $tpl->assign('note', $this->mActionForm->get('note'));
     } else {
         $tpl->assign('note', XCube_Utils::formatString(_MD_MESSAGE_MAILBODY, XOOPS_URL . '/'));
     }
     $tpl->assign('siteurl', XOOPS_URL . '/');
     return $tpl->fetch(_MY_MODULE_PATH . 'language/' . $this->root->mLanguageManager->mLanguageName . '/invitation.tpl');
 }
 function _saveAvatarImages(&$avatarimages)
 {
     if (count($avatarimages) == 0) {
         return true;
     }
     $avatarhandler =& xoops_getmodulehandler('avatar');
     for ($i = 0; $i < count($avatarimages); $i++) {
         $ext_pos = strrpos($avatarimages[$i]['name'], '.');
         if ($ext_pos === false) {
             continue;
         }
         $ext = strtolower(substr($avatarimages[$i]['name'], $ext_pos + 1));
         if (empty($this->mAllowedExts[$ext])) {
             continue;
         }
         $file_name = substr($avatarimages[$i]['name'], 0, $ext_pos);
         $save_file_name = uniqid('savt') . '.' . $ext;
         $filehandle = fopen(XOOPS_UPLOAD_PATH . '/' . $save_file_name, "w");
         if (!$filehandle) {
             $this->_addErrorMessage(XCube_Utils::formatString(_AD_USER_ERROR_COULD_NOT_SAVE_AVATAR_FILE, $file_name));
             continue;
         }
         if (!@fwrite($filehandle, $avatarimages[$i]['content'])) {
             $this->_addErrorMessage(XCube_Utils::formatString(_AD_USER_ERROR_COULD_NOT_SAVE_AVATAR_FILE, $file_name));
             @fclose($filehandle);
             continue;
         }
         @fclose($filehandle);
         $avatar =& $avatarhandler->create();
         $avatar->set('avatar_name', $file_name);
         $avatar->set('avatar_file', $save_file_name);
         $avatar->set('avatar_display', 1);
         $avatar->set('avatar_weight', 0);
         $avatar->set('avatar_type', 'S');
         $avatar->set('avatar_mimetype', $this->mAllowedExts[$ext]);
         if (!$avatarhandler->insert($avatar)) {
             $this->_addErrorMessage(XCube_Utils::formatString(_AD_USER_ERROR_COULD_NOT_SAVE_AVATAR_FILE, $file_name));
         }
         unset($avatar);
     }
     return true;
 }
 function validatePasswd()
 {
     if (strlen($this->get('login')) > 0 && strlen($this->get('passwd')) == 0) {
         $this->addErrorMessage(XCube_Utils::formatMessage(_AD_LEGACYRENDER_ERROR_REQUIRED, _AD_LEGACYRENDER_LANG_PASSWD));
     }
 }
 function validatePass()
 {
     // precondition check
     if (strlen($this->get('pass')) > 0 && !preg_match('/^[\\x21-\\x7e]+$/', $this->get('pass'))) {
         $this->addErrorMessage(XCube_Utils::formatString(_MD_USER_ERROR_INJURY, _MD_USER_LANG_PASSWORD));
         $this->set('pass', null);
         // reset
         $this->set('vpass', null);
     }
     if (strlen($this->get('pass')) > 0 || strlen($this->get('vpass')) > 0) {
         if ($this->get('pass') != $this->get('vpass')) {
             $this->addErrorMessage(_MD_USER_ERROR_PASSWORD);
             $this->set('pass', null);
             // reset
             $this->set('vpass', null);
         }
     }
 }
示例#26
0
 /**
  * @public
  * @brief Gets the error message rendered by XCube_Utils::formaString().
  * @param $name string - Depend rule name
  * @return string
  * 
  *   Gets the error message registered at addMessage(). If the message setting has some
  *   arguments, messages are rendered by XCube_Utils::formatString().
  * \code
  *   $field->addMessage('required', "{0:ucFirst} is requred.", "name");
  * 
  *   // Gets "Name is required."
  *   $field->renderMessage('required');
  * \endcode
  *   This feature is helpful for automatic ActionForm generators.
  */
 function renderMessage($name)
 {
     if (!isset($this->mMessages[$name])) {
         return null;
     }
     $message = $this->mMessages[$name]['message'];
     if (isset($this->mMessages[$name]['args'])) {
         // Use an unity method.
         $message = XCube_Utils::formatString($message, $this->mMessages[$name]['args']);
     }
     return $message;
 }
示例#27
0
 /**
  * _processReport
  * 
  * @param   void
  * 
  * @return  void
  **/
 private function _processReport()
 {
     if (!$this->mLog->hasError()) {
         $this->mLog->add(XCube_Utils::formatString(_MI_XCCK_INSTALL_MSG_MODULE_UNINSTALLED, $this->_mXoopsModule->get('name')));
     } else {
         if (is_object($this->_mXoopsModule)) {
             $this->mLog->addError(XCube_Utils::formatString(_MI_XCCK_INSTALL_MSG_MODULE_UNINSTALLED, $this->_mXoopsModule->get('name')));
         } else {
             $this->mLog->addError(XCube_Utils::formatString(_MI_XCCK_INSTALL_MSG_MODULE_UNINSTALLED, 'something'));
         }
     }
 }
 /**
  * process report.
  */
 private function _processReport()
 {
     $dirname = $this->_mXoopsModule->get('dirname');
     $constpref = '_MI_' . strtoupper($dirname);
     if (!$this->mLog->hasError()) {
         $this->mLog->add(XCube_Utils::formatString(constant($constpref . '_INSTALL_MSG_MODULE_UNINSTALLED'), $this->_mXoopsModule->get('name')));
     } elseif (is_object($this->_mXoopsModule)) {
         $this->mLog->addError(XCube_Utils::formatString(constant($constpref . '_INSTALL_ERROR_MODULE_UNINSTALLED'), $this->_mXoopsModule->get('name')));
     } else {
         $this->mLog->addError(XCube_Utils::formatString(constant($constpref . '_INSTALL_ERROR_MODULE_UNINSTALLED'), 'something'));
     }
 }
示例#29
0
 /**
  * _processReport
  * 
  * @param   void
  * 
  * @return  void
  **/
 private function _processReport()
 {
     if (!$this->mLog->hasError()) {
         $this->mLog->add(XCube_Utils::formatString(_MI_XUPDATE_INSTALL_MSG_MODULE_UPDATED, $this->_mCurrentXoopsModule->get('name')));
     } else {
         $this->mLog->add(XCube_Utils::formatString(_MI_XUPDATE_INSTALL_ERROR_MODULE_UPDATED, $this->_mCurrentXoopsModule->get('name')));
     }
 }
示例#30
0
 function _processReport()
 {
     if (!$this->mLog->hasError()) {
         $this->mLog->add(XCube_Utils::formatString(_AD_LEGACY_MESSAGE_INSTALLATION_MODULE_SUCCESSFUL, $this->_mXoopsModule->get('name')));
     } else {
         $this->mLog->addError(XCube_Utils::formatString(_AD_LEGACY_ERROR_INSTALLATION_MODULE_FAILURE, $this->_mXoopsModule->get('name')));
     }
 }