本文整理汇总了PHP中Phpfox_Error::isPassed方法的典型用法代码示例。如果您正苦于以下问题:PHP Phpfox_Error::isPassed方法的具体用法?PHP Phpfox_Error::isPassed怎么用?PHP Phpfox_Error::isPassed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phpfox_Error
的用法示例。
在下文中一共展示了Phpfox_Error::isPassed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: changeEmail
/**
* Changes a user's email addres, checks if user is allowed and if he should be made verify their email address
* afterwards and if it should be logged out immediately after changing it.
* @param <type> $aUser
* @param <type> $sMail
* @return <type>
*/
public function changeEmail($aUser, $sMail)
{
// check if user has enough permissions and the mails dont match if they have to verify the new email upon signup it
if (Phpfox::getUserGroupParam($aUser['user_group_id'], 'user.can_change_email')) {
Phpfox::getService('user.validate')->email($sMail);
if (!Phpfox_Error::isPassed()) {
return false;
}
// check that the new email is not in use.
$sEmail = Phpfox::getLib('parse.input')->prepare($sMail);
$inUse = $this->database()->select('email')->where('email = \'' . $sEmail . '\'')->from(Phpfox::getT('user'))->execute('getSlaveField');
if ($inUse != '') {
return 'Email address already in use';
}
//die(d(Phpfox::getParam('user.verify_email_at_signup'), true));
// set the status to need to be verified only if they are required at signup
if (Phpfox::getParam('user.verify_email_at_signup')) {
$mUser = array('user_id' => $aUser['user_id'], 'email' => Phpfox::getLib('parse.input')->prepare($sMail), 'password' => $aUser['password']);
$this->database()->update(Phpfox::getT('user'), array('status_id' => 1), 'user_id = ' . (int) $aUser['user_id']);
$this->sendMail($mUser);
} else {
// just change the email
$this->database()->update(Phpfox::getT('user'), array('email' => Phpfox::getLib('parse.input')->prepare($sMail)), 'user_id = ' . (int) $aUser['user_id']);
}
//Phpfox::getParam('user.logout_after_change_email_if_verify') && Phpfox::getParam('user.verify_email_at_signup')
// check if they should be logged out immediately after changing it. Only then should their status_id be changed
if (Phpfox::getParam('user.verify_email_at_signup') && Phpfox::getParam('user.logout_after_change_email_if_verify') == true) {
Phpfox::getService('user.auth')->logout();
}
return true;
}
return false;
}
示例2: process
/**
* Class process method wnich is used to execute this component.
*/
public function process()
{
if ($aVals = $this->request()->getArray('val')) {
Phpfox::isUser(true);
Phpfox::getUserParam('comment.can_post_comments', true);
if (($iFlood = Phpfox::getUserParam('comment.comment_post_flood_control')) !== 0) {
$aFlood = array('action' => 'last_post', 'params' => array('field' => 'time_stamp', 'table' => Phpfox::getT('comment'), 'condition' => 'type_id = \'' . Phpfox::getLib('database')->escape($aVals['type']) . '\' AND user_id = ' . Phpfox::getUserId(), 'time_stamp' => $iFlood * 60));
// actually check if flooding
if (Phpfox::getLib('spam')->check($aFlood)) {
Phpfox_Error::set(Phpfox::getPhrase('comment.posting_a_comment_a_little_too_soon_total_time', array('total_time' => Phpfox::getLib('spam')->getWaitTime())));
}
}
if (Phpfox::getLib('parse.format')->isEmpty($aVals['text'])) {
Phpfox_Error::set(Phpfox::getPhrase('feed.add_some_text_to_your_comment'));
}
if (Phpfox_Error::isPassed() && ($iId = Phpfox::getService('comment.process')->add($aVals))) {
$this->url()->send('feed.view', array('id' => $this->request()->getInt('id')), Phpfox::getPhrase('feed.successfully_added_your_comment'));
}
}
if ($iLikeType = $this->request()->getInt('liketype')) {
if (Phpfox::getService('feed.process')->like($this->request()->getInt('id'), $iLikeType)) {
$this->url()->send('feed.view', array('id' => $this->request()->getInt('id')), $iLikeType == '1' ? Phpfox::getPhrase('feed.successfully_liked_this_feed') : Phpfox::getPhrase('feed.successfully_unliked_this_feed'));
}
}
list($iFeedCount, $aFeeds) = Phpfox::getService('feed')->get(null, $this->request()->getInt('id'), 1);
$iCommentCnt = 0;
$aComments = array();
if (Phpfox::getParam('feed.allow_comments_on_feeds')) {
list($iCommentCnt, $aComments) = Phpfox::getService('comment')->get('cmt.*', array("AND cmt.type_id = 'feed'", 'AND cmt.item_id = ' . (int) $aFeeds[0]['feed_id'], 'AND cmt.view_id = 0'), 'cmt.time_stamp ASC');
}
if (!count($aFeeds)) {
return Phpfox_Error::display(Phpfox::getPhrase('feed.not_a_valid_feed'));
}
$this->template()->setMobileHeader(array('feed.css' => 'module_feed'))->assign(array('iFeedId' => $aFeeds[0]['feed_id'], 'aFeeds' => $aFeeds, 'aComments' => $aComments));
}
示例3: add
/**
* Adds a new cancellation option to be shown when a user wants to delete their account
* Looks like its working when adding, @todo Purefan: test it works for editing as well.
* @param array $aVals
* @param int $iUpdateId Optional param to tell if we're editing
* @return boolean
*/
public function add($aVals)
{
$aForm = array('product_id' => array('message' => Phpfox::getPhrase('user.select_a_product'), 'type' => 'product_id:required'), 'module_id' => array('message' => Phpfox::getPhrase('user.select_a_module'), 'type' => 'module_id:required'), 'phrase_var' => array('message' => Phpfox::getPhrase('user.you_need_to_add_a_message_to_show'), 'type' => 'phrase:required'), 'is_active' => array('message' => Phpfox::getPhrase('user.select_if_the_cancellation_option_is_active_or_not'), 'type' => 'int:required'));
$iUpdateId = isset($aVals['iDeleteId']) ? (int) $aVals['iDeleteId'] : null;
if ($iUpdateId !== null) {
unset($aForm['product_id'], $aForm['module_id']);
$aVals = $this->validator()->process($aForm, $aVals);
if (!Phpfox_Error::isPassed()) {
return false;
}
$aPhrases = $aVals['phrase_var'];
unset($aVals['phrase_var']);
$this->database()->update($this->_sTable, $aVals, 'delete_id = ' . $iUpdateId);
// Updates the language phrases for every language
foreach ($aPhrases as $sPhrase => $aPhrase) {
$aLanguage = array_keys($aPhrase);
$aText = array_values($aPhrase);
Phpfox::getService('language.phrase.process')->updateVarName($aLanguage[0], $sPhrase, $aText[0]);
}
} else {
$aVals = $this->validator()->process($aForm, $aVals);
if (!Phpfox_Error::isPassed()) {
return false;
}
$aPhrases = $aVals['phrase_var'];
$aVals['phrase_var'] = '';
$iId = $this->database()->insert($this->_sTable, $aVals);
$sPhraseVar = Phpfox::getService('language.phrase.process')->add(array('var_name' => 'user_cancellation_' . $iId, 'product_id' => $aVals['product_id'], 'module' => $aVals['module_id'] . '|' . $aVals['module_id'], 'text' => $aPhrases));
$this->database()->update($this->_sTable, array('phrase_var' => $sPhraseVar), 'delete_id = ' . $iId);
}
$this->cache()->remove('user_cancellations');
return true;
}
示例4: add
public function add($aVals, $iUpdateId = null)
{
$aForm = array('currency_id' => array('message' => Phpfox::getPhrase('admincp.provide_a_3_character_currency_id'), 'type' => 'string:required'), 'symbol' => array('message' => Phpfox::getPhrase('admincp.provide_a_symbol'), 'type' => 'string:required'), 'phrase_var' => array('message' => Phpfox::getPhrase('admincp.provide_a_phrase_for_your_currency'), 'type' => 'phrase:required'), 'is_active' => array('message' => Phpfox::getPhrase('admincp.select_if_this_currency_is_active_or_not'), 'type' => 'int:required'));
$aVals = $this->validator()->process($aForm, $aVals);
if (!Phpfox_Error::isPassed()) {
return false;
}
$aVals['symbol'] = $this->preParse()->clean($aVals['symbol']);
if ($iUpdateId !== null) {
if ($iUpdateId != $aVals['currency_id']) {
$iCheck = $this->database()->select('COUNT(*)')->from($this->_sTable)->where('currency_id = \'' . $this->database()->escape($aVals['currency_id']) . '\'')->execute('getField');
if ($iCheck) {
return Phpfox_Error::set(Phpfox::getPhrase('admincp.this_currency_is_already_in_use'));
}
}
$aPhrases = $aVals['phrase_var'];
unset($aVals['phrase_var']);
$this->database()->update($this->_sTable, $aVals, 'currency_id = \'' . $this->database()->escape($iUpdateId) . '\'');
foreach ($aPhrases as $sPhrase => $aPhrase) {
$aLanguage = array_keys($aPhrase);
$aText = array_values($aPhrase);
Phpfox::getService('language.phrase.process')->updateVarName($aLanguage[0], $sPhrase, $aText[0]);
}
} else {
$iCheck = $this->database()->select('COUNT(*)')->from($this->_sTable)->where('currency_id = \'' . $this->database()->escape($aVals['currency_id']) . '\'')->execute('getField');
if ($iCheck) {
return Phpfox_Error::set(Phpfox::getPhrase('admincp.this_currency_is_already_in_use'));
}
$this->database()->insert($this->_sTable, $aVals);
$sPhraseVar = Phpfox::getService('language.phrase.process')->add(array('var_name' => 'custom_currency_' . $aVals['currency_id'], 'product_id' => 'phpfox', 'module' => 'core|core', 'text' => $aVals['phrase_var']));
$this->database()->update($this->_sTable, array('phrase_var' => $sPhraseVar), 'currency_id = \'' . $this->database()->escape($aVals['currency_id']) . '\'');
}
$this->cache()->remove('currency');
return true;
}
示例5: process
public function process()
{
error_reporting(E_ALL);
if ($aVals = $this->request()->get('val')) {
if (!empty($aVals['sv_subfolder'])) {
if (preg_match('/[^A-Za-z0-9-_.\\/]/', $aVals['sv_subfolder'])) {
$invalid_character = 'The sub directory must only contain alphanumeric characters.';
return Phpfox_Error::set($invalid_character);
}
}
if (Phpfox_Error::isPassed()) {
//Save backup settings
Phpfox::getService('backuprestore.settings')->saveBackupSettings($aVals);
}
}
// Default time values
if (!($setting = Phpfox::getService('backuprestore.settings')->getBackupSettings())) {
Phpfox::getService('backuprestore.settings')->setDefaultSettings();
}
//Time settings
$hours = array();
$minutes = array();
for ($i = 0; $i <= 24; $i++) {
$hours[$i] = $i;
}
for ($i = 0; $i <= 59; $i++) {
$minutes[$i] = $i;
}
$this->template()->assign(array('timefreqs' => array('Each 6 hours', 'Daily', 'Every 3 days', 'Weakly', 'Monthly'), 'hours' => $hours, 'minutes' => $minutes, 'aForms' => Phpfox::getService('backuprestore.settings')->getBackupSettings()));
$this->template()->setBreadcrumb(Phpfox::getPhrase('backuprestore.backup_settings'), $this->url()->makeUrl('admincp.backuprestore.setting'))->setHeader(array('btdbstyles.css' => 'module_backuprestore', 'scripts.js' => 'module_backuprestore'));
}
示例6: addThread
/**
* Add thread
* @param $iFourmId
* @param $sTitle
* @param $sText
* @param $iSubscribed
* @return bool|null
*/
public function addThread($iFourmId, $sTitle, $sText, $iSubscribed)
{
$aForum = Phpfox::getService('forum')->id($iFourmId)->getForum();
if (!isset($aForum['forum_id'])) {
return Phpfox_Error::display(Phpfox::getPhrase('forum.not_a_valid_forum'));
}
if ($aForum['is_closed']) {
return Phpfox_Error::display(Phpfox::getPhrase('forum.forum_is_closed'));
}
$bPass = false;
if (Phpfox::getUserParam('forum.can_add_new_thread') || Phpfox::getService('forum.moderate')->hasAccess($aForum['forum_id'], 'add_thread')) {
$bPass = true;
}
if ($bPass === false) {
return Phpfox_Error::display(Phpfox::getPhrase('forum.insufficient_permission_to_reply_to_this_thread'));
}
$aVals = array('forum_id' => $iFourmId, 'title' => $sTitle, 'text' => $sText, 'is_subscribed' => $iSubscribed);
if (($iFlood = Phpfox::getUserParam('forum.forum_thread_flood_control')) !== 0) {
$aFlood = array('action' => 'last_post', 'params' => array('field' => 'time_stamp', 'table' => Phpfox::getT('forum_thread'), 'condition' => 'user_id = ' . Phpfox::getUserId(), 'time_stamp' => $iFlood * 60));
// actually check if flooding
if (Phpfox::getLib('spam')->check($aFlood)) {
Phpfox_Error::set(Phpfox::getPhrase('forum.posting_a_new_thread_a_little_too_soon') . ' ' . Phpfox::getLib('spam')->getWaitTime());
}
}
//add thread
if (Phpfox_Error::isPassed() && ($iId = Phpfox::getService('forum.thread.process')->add($aVals, false))) {
//return thread
return $this->getThreadById($iId, 1, 10, null);
}
return null;
}
示例7: add
/**
* Adds a new job to send the newsletter, first there is no cron jobs/tabs so this function's return
* directs the flow of the script (refresh) to process the batches.
* Sets the errors using Phpfox_Error::set
* @param <type> $aVals
* @return Int Next round to process | false on error.
*/
public function add($aVals, $iUser)
{
// Check validations using the new method
$aForm = array('subject' => array('message' => Phpfox::getPhrase('newsletter.add_a_subject'), 'type' => 'string:required'), 'total' => array('message' => Phpfox::getPhrase('newsletter.how_many_users_to_contact_per_round'), 'type' => 'int:required'), 'text' => array('message' => Phpfox::getPhrase('newsletter.you_need_to_write_a_message_to_send'), 'type' => 'string:required'));
$aVals['type_id'] = 2;
// Internal newsletters are deprecated since 3.3.0 beta 1
$this->validator()->process($aForm, $aVals);
if (!Phpfox_Error::isPassed()) {
return false;
}
// Phpfox::getService('ban')->checkAutomaticBan($aVals['subject'] . ' ' . $aVals['text'] . ' ' . $aVals['txtPlain']);
$iActive = $this->database()->select('COUNT(newsletter_id)')->from($this->_sTable)->where('state = 1')->execute('getSlaveField');
// insert the values in the database
$aInsert = array('subject' => $this->preParse()->clean($aVals['subject']), 'round' => 0, 'state' => $iActive > 0 ? 0 : 1, 'age_from' => (int) $aVals['age_from'], 'age_to' => (int) $aVals['age_to'], 'type_id' => (int) $aVals['type_id'], 'country_iso' => $this->preParse()->clean($aVals['country_iso']), 'gender' => (int) $aVals['gender'], 'user_group_id' => '', 'total' => (int) $aVals['total'], 'user_id' => (int) $iUser, 'time_stamp' => Phpfox::getTime(), 'archive' => isset($aVals['archive']) ? (int) $aVals['archive'] : 2, 'privacy' => isset($aVals['privacy']) ? (int) $aVals['privacy'] : 2);
if (isset($aVals['is_user_group']) && $aVals['is_user_group'] == 2) {
$aGroups = array();
$aUserGroups = Phpfox::getService('user.group')->get();
if (isset($aVals['user_group'])) {
foreach ($aUserGroups as $aUserGroup) {
if (in_array($aUserGroup['user_group_id'], $aVals['user_group'])) {
$aGroups[] = $aUserGroup['user_group_id'];
}
}
}
$aInsert['user_group_id'] = count($aGroups) ? serialize($aGroups) : null;
}
// ** when we implement the cron job this is the place to set the state differently
$iId = $this->database()->insert($this->_sTable, $aInsert);
$this->database()->insert(Phpfox::getT('newsletter_text'), array('newsletter_id' => $iId, 'text_plain' => $this->preParse()->clean($aVals['txtPlain']), 'text_html' => $aVals['text']));
// store that we are processing a job
$aInsert['newsletter_id'] = $iId;
$aInsert['round'] = 0;
return $aInsert;
}
示例8: process
/**
* Controller
* This controller handles invalid user group by 2 means:
* 1. getInt('id',0) => if no user group is given its explicitly redirected
* 2. getActivityPoints may return a Phpfox_Error
*/
public function process()
{
$iGroupId = $this->request()->getInt('id', 0);
$aPoints = Phpfox::getService('user.group.setting')->getActivityPoints($iGroupId);
if ($aVals = $this->request()->getArray('val')) {
$oService = Phpfox::getService('user.group.setting.process');
$aUpdate = array();
foreach ($aVals['module'] as $iSetting => $iValue) {
foreach ($aPoints as $iKey => $aPoint) {
if ($aPoint['setting_id'] == $iSetting && $iValue != $aPoint['value_actual']) {
$aUpdate['value_actual'][$iSetting] = $iValue;
/* Update the array to show the change in the template without calling DB again */
$aPoints[$iKey]['value_actual'] = $iValue;
}
}
}
if (!empty($aUpdate)) {
$oService->update($aVals['igroup'], $aUpdate);
}
$iGroupId = $aVals['igroup'];
} else {
if ($iGroupId == 0) {
$this->url()->send('admincp.user.group', null, Phpfox::getPhrase('user.invalid_user_group'));
}
}
$sUserGroup = Phpfox::getService('user.group')->getGroup($iGroupId);
if (!Phpfox_Error::isPassed()) {
$aError = array_unique(Phpfox_Error::get());
$sMessage = implode(', ', $aError);
$this->url()->send('admincp.user.group', null, $sMessage);
}
$this->template()->setBreadcrumb('Manage Activity Points', $this->url()->makeUrl('current'), true)->setTitle('Manage Activity Points')->assign(array('aPoints' => $aPoints, 'aUserGroup' => $sUserGroup))->setHeader(array('activitypoints.css' => 'module_user'));
}
示例9: addSlide
public function addSlide($aVals, $iEditId = null)
{
$aForm = array('slide_title' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('bootstraptheme.slide_title_fill')), 'slide_description' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('bootstraptheme.slide_description_fill')), 'slide_position' => array('type' => 'string'), 'button_label' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('bootstraptheme.slide_button_label_fill')), 'button_color' => array('type' => 'string'), 'button_text_color' => array('type' => 'string'), 'button_link' => array('type' => 'string'), 'is_active' => array('type' => 'int'));
$aVals = $this->validator()->process($aForm, $aVals);
if (!Phpfox_Error::isPassed()) {
return false;
}
$aVals['slide_title'] = $this->preParse()->clean($aVals['slide_title']);
$aVals['slide_description'] = $this->preParse()->clean($aVals['slide_description']);
if ($iEditId === null) {
$aVals['slide_url'] = Phpfox::getLib('parse.input')->cleanFileName(uniqid());
if (!($aVals['slide_url'] = $this->_uploadImage($aVals['slide_url']))) {
return false;
}
$this->database()->insert($this->_sTable, $aVals);
} else {
if (!empty($_FILES['slide_url']['name'])) {
$aVals['slide_url'] = Phpfox::getLib('parse.input')->cleanFileName(uniqid());
$aOld = $this->getSlideForEdit($iEditId);
if (file_exists(Phpfox::getParam('bootstraptheme.bootstraptheme_dir_image') . $aOld['slide_url'])) {
Phpfox::getLib('file')->unlink(Phpfox::getParam('bootstraptheme.bootstraptheme_dir_image') . $aOld['slide_url']);
}
if (!($aVals['slide_url'] = $this->_uploadImage($aVals['slide_url']))) {
return false;
}
}
$this->database()->update($this->_sTable, $aVals, 'slide_id = ' . (int) $iEditId);
}
$this->cache()->remove('bootstraptheme', 'substr');
return true;
}
示例10: add
public function add($aVals, $iUpdateId = null)
{
$aForm = array('product_id' => array('message' => Phpfox::getPhrase('admincp.select_a_product'), 'type' => 'product_id:required'), 'module_id' => array('message' => Phpfox::getPhrase('admincp.select_a_module'), 'type' => 'module_id:required'), 'phrase_var' => array('message' => Phpfox::getPhrase('admincp.at_least_one_title_for_the_stat_is_required'), 'type' => 'phrase:required'), 'stat_link' => array('message' => Phpfox::getPhrase('admincp.link_for_the_stat_is_required'), 'type' => 'string:required'), 'stat_image' => array('message' => Phpfox::getPhrase('admincp.image_for_the_stat_is_required'), 'type' => 'string'), 'php_code' => array('message' => Phpfox::getPhrase('admincp.php_code_for_the_stat_is_required'), 'type' => 'php_code:required'), 'is_active' => array('message' => Phpfox::getPhrase('admincp.select_if_the_stat_is_active_or_not'), 'type' => 'int:required'));
if ($iUpdateId !== null) {
unset($aForm['product_id'], $aForm['module_id']);
$aVals = $this->validator()->process($aForm, $aVals);
if (!Phpfox_Error::isPassed()) {
return false;
}
$aPhrases = $aVals['phrase_var'];
unset($aVals['phrase_var']);
$this->database()->update($this->_sTable, $aVals, 'stat_id = ' . $iUpdateId);
foreach ($aPhrases as $sPhrase => $aPhrase) {
$aLanguage = array_keys($aPhrase);
$aText = array_values($aPhrase);
Phpfox::getService('language.phrase.process')->updateVarName($aLanguage[0], $sPhrase, $aText[0]);
}
} else {
$aVals = $this->validator()->process($aForm, $aVals);
if (!Phpfox_Error::isPassed()) {
return false;
}
$aPhrases = $aVals['phrase_var'];
unset($aVals['phrase_var']);
$iId = $this->database()->insert($this->_sTable, $aVals);
$sPhraseVar = Phpfox::getService('language.phrase.process')->add(array('var_name' => 'stat_title_' . $iId, 'product_id' => $aVals['product_id'], 'module' => $aVals['module_id'] . '|' . $aVals['module_id'], 'text' => $aPhrases));
$this->database()->update($this->_sTable, array('phrase_var' => $sPhraseVar), 'stat_id = ' . $iId);
}
$this->cache()->remove('stat', 'substr');
return true;
}
示例11: add
public function add($aVals, $iEditId = null)
{
$aForm = array('type_id' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('share.select_what_type_of_a_site_this_is')), 'title' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('share.provide_a_name_for_the_site')), 'url' => array('type' => 'string:required', 'message' => Phpfox::getPhrase('share.provide_a_url_for_the_site')), 'is_active' => array('type' => 'int:required'));
$aVals = $this->validator()->process($aForm, $aVals);
if (!Phpfox_Error::isPassed()) {
return false;
}
Phpfox::getService('ban')->checkAutomaticBan($aVals['title']);
$aVals['title'] = $this->preParse()->clean($aVals['title']);
if ($iEditId === null) {
$iCheck = $this->database()->select('COUNT(*)')->from($this->_sTable)->where('title = \'' . $this->database()->escape($aVals['title']) . '\'')->execute('getField');
if ($iCheck) {
return Phpfox_Error::set(Phpfox::getPhrase('share.this_site_already_exists'));
}
$aVals['icon'] = Phpfox::getLib('parse.input')->cleanFileName($aVals['title']);
if (!($aVals['icon'] = $this->_uploadImage($aVals['icon']))) {
return false;
}
$this->database()->insert($this->_sTable, $aVals);
} else {
if (!empty($_FILES['icon']['name'])) {
$aVals['icon'] = Phpfox::getLib('parse.input')->cleanFileName($aVals['title']);
$aOld = Phpfox::getService('share')->getForEdit($iEditId);
if (file_exists(Phpfox::getParam('share.dir_image') . $aOld['icon'])) {
Phpfox::getLib('file')->unlink(Phpfox::getParam('share.dir_image') . $aOld['icon']);
}
if (!($aVals['icon'] = $this->_uploadImage($aVals['icon']))) {
return false;
}
}
$this->database()->update($this->_sTable, $aVals, 'site_id = ' . (int) $iEditId);
}
$this->cache()->remove('share', 'substr');
return true;
}
示例12: addText
/**
* This function is only called from the ajax function im.add
* @param type $aVals
* @return type
*/
public function addText($aVals)
{
Phpfox::isUser(true);
$aValid = array('parent_id' => array('type' => 'int:required'), 'text' => array('type' => 'string:required'));
if (isset($aVals['text']) && Phpfox::getLib('parse.format')->isEmpty($aVals['text']) && $aVals['text'] != '0') {
return false;
}
$aVals = $this->validator()->allowZero()->process($aValid, $aVals);
// Cant use validator because "0" is considered empty
//$aVals['text'] = Phpfox::getLib('parse.input')->clean($aVals['text']);
if (!Phpfox_Error::isPassed()) {
return false;
}
$aChat = Phpfox::getService('im')->getChat($aVals['parent_id']);
if (!isset($aChat['im_id'])) {
return Phpfox_Error::set(Phpfox::getPhrase('im.not_a_valid_chat_room'));
}
if (!$aChat['is_logged_in']) {
return Phpfox_Error::set(Phpfox::getPhrase('im.unable_to_send_this_user_an_offline_message'));
}
Phpfox::getService('ban')->checkAutomaticBan($aVals['text']);
$aVals['user_id'] = Phpfox::getUserId();
$aVals['time_stamp'] = PHPFOX_TIME;
$aVals['text'] = $this->preParse()->clean($aVals['text']);
//if ($sPlugin = Phpfox_Plugin::get('im.service_process_addtext_pre_insert')){eval($sPlugin);}
$iId = $this->database()->insert(Phpfox::getT('im_text'), $aVals);
if ($sPlugin = Phpfox_Plugin::get('im.service_process_addtext_1')) {
eval($sPlugin);
if (isset($mReturnFromPlugin)) {
return $mReturnFromPlugin;
}
}
//$this->database()->update($this->_sTable, array('is_active' => '1', 'last_update' => PHPFOX_TIME), 'parent_id = ' . $aVals['parent_id'] . '');
/* Check if the other user has this chat conversation open */
$aOpen = $this->database()->select('is_active, is_new')->from($this->_sTable)->where('parent_id = ' . (int) $aVals['parent_id'])->execute('getSlaveRow');
$aUpdate = array();
if ($aOpen['is_new'] = 0) {
//$aUpdate = array('is_new' => $iId);
}
if ($aOpen['is_active'] != 2) {
$aUpdate['is_active'] = '1';
}
if (!empty($aUpdate)) {
//$this->database()->update($this->_sTable, $aUpdate, 'parent_id = ' . $aVals['parent_id'] . ' AND owner_user_id = ' . Phpfox::getUserId());
}
if (Phpfox::getService('im')->canAddAlert($aChat['user_id'], $aChat['parent_id'])) {
$this->addAlert($aChat['user_id'], $aChat['parent_id']);
}
// http://www.phpfox.com/tracker/view/15335/
$sCacheId = $this->cache()->set('chat_rooms_user_' . $aChat['owner_user_id']);
if ($aChatData = $this->cache()->get($sCacheId)) {
$aChatData['room_id'][$aChat['parent_id']] = Phpfox::getUserId();
} else {
$aChatData = array('room_id' => array($aChat['parent_id'] => Phpfox::getUserId()));
}
$sCacheId = $this->cache()->set('chat_rooms_user_' . $aChat['owner_user_id']);
$this->cache()->save($sCacheId, $aChatData);
return true;
}
示例13: upgrade
public function upgrade()
{
$this->error(false);
Phpfox::getBlock('subscribe.upgrade', array('bIsThickBox' => true));
// http://www.phpfox.com/tracker/view/15093/
if (!Phpfox_Error::isPassed()) {
echo '<div class="error_message">' . implode('<br />', Phpfox_Error::get()) . '</div>';
}
}
示例14: export
public function export($aVals)
{
if (empty($aVals['title'])) {
Phpfox_Error::set('Provide a package name.');
}
if (empty($aVals['url'])) {
Phpfox_Error::set('Provide a URL.');
}
if (empty($aVals['apps'])) {
Phpfox_Error::set('Select apps to export.');
}
if (Phpfox_Error::isPassed()) {
$aVals['title'] = strtolower($aVals['title']);
$aVals['title'] = preg_replace('/[^a-zA-Z0-9]+/', '', $aVals['title']);
$aVals['title'] = substr($aVals['title'], 0, 20);
define('PHPFOX_XML_SKIP_STAMP', true);
$oXmlBuilder = Phpfox::getLib('xml.builder');
$oXmlBuilder->addGroup('phpfoxapps');
$oXmlBuilder->addGroup('appsinfo');
$oXmlBuilder->addTag('url', $aVals['url']);
$oXmlBuilder->closeGroup();
$oXmlBuilder->addGroup('apps');
$aApps = $this->getAllApps($aVals['apps']);
foreach ($aApps as $aApp) {
$oXmlBuilder->addGroup('app');
$oXmlBuilder->addTag('app_title', $aApp['app_title']);
$oXmlBuilder->addTag('app_description', $aApp['app_description']);
$oXmlBuilder->addTag('app_url', $aApp['app_url']);
$oXmlBuilder->addTag('image_url', $aApp['image_url']);
$oXmlBuilder->addTag('time_stamp', $aApp['time_stamp']);
if (!empty($aApp['image_path'])) {
$oXmlBuilder->addGroup('images');
$aSizes = array('', 50, 200, 'square');
foreach ($aSizes as $mSize) {
$sImage = sprintf($aApp['image_path'], empty($mSize) ? '' : '_' . $mSize);
$sContent = file_get_contents(PHPFOX_DIR . 'file' . PHPFOX_DS . 'pic' . PHPFOX_DS . 'app' . PHPFOX_DS . $sImage);
$aExts = preg_split('/[\\/\\.]/', $sImage);
$iCnt = count($aExts) - 1;
$sExt = strtolower($aExts[$iCnt]);
$oXmlBuilder->addTag('data', base64_encode($sContent), array('id' => md5($sContent), 'size' => empty($mSize) ? '' : '_' . $mSize, 'ext' => $sExt));
}
$oXmlBuilder->closeGroup();
}
$oXmlBuilder->closeGroup();
}
$oXmlBuilder->closeGroup();
$oXmlBuilder->closeGroup();
$sNewHomeFolder = PHPFOX_DIR_CACHE . md5(uniqid() . Phpfox::getUserId());
Phpfox::getLib('file')->write($sNewHomeFolder, $oXmlBuilder->output());
Phpfox::getLib('file')->forceDownload($sNewHomeFolder, 'phpfox-' . $aVals['title'] . '.apps');
}
return false;
}
示例15: add
public function add($aVals, $iUpdateId = null)
{
$aForms = array('title' => array('message' => Phpfox::getPhrase('subscribe.provide_a_message_for_the_package'), 'type' => array('string:required')), 'description' => array('message' => Phpfox::getPhrase('subscribe.provide_a_description_for_the_package'), 'type' => 'string:required'), 'user_group_id' => array('message' => Phpfox::getPhrase('subscribe.provide_a_user_group_on_success'), 'type' => 'int:required'), 'fail_user_group' => array('message' => Phpfox::getPhrase('subscribe.provide_a_user_group_on_cancellation'), 'type' => 'int:required'), 'is_registration' => array('message' => Phpfox::getPhrase('subscribe.provide_if_the_package_should_be_added_to_the_registration_form'), 'type' => 'int:required'), 'is_active' => array('message' => Phpfox::getPhrase('subscribe.select_if_the_package_is_active_or_not'), 'type' => 'int:required'), 'cost' => array('message' => Phpfox::getPhrase('subscribe.provide_a_price_for_the_package'), 'type' => 'currency:required'), 'show_price' => array('type' => 'int:required'), 'background_color' => array('type' => 'string'));
$bIsRecurring = false;
if (isset($aVals['is_recurring']) && $aVals['is_recurring']) {
$aForms['recurring_cost'] = array('message' => Phpfox::getPhrase('subscribe.provide_a_recurring_cost'), 'type' => 'currency:required');
$aForms['recurring_period'] = array('message' => Phpfox::getPhrase('subscribe.provide_a_recurring_period'), 'type' => 'int:required');
$bIsRecurring = true;
}
if ($iUpdateId !== null) {
if (isset($aVals['is_recurring']) && !$aVals['is_recurring']) {
$aCacheForm = $aVals;
}
}
$aVals = $this->validator()->process($aForms, $aVals);
if (!Phpfox_Error::isPassed()) {
return false;
}
if ($iUpdateId !== null) {
if (isset($aCacheForm['is_recurring']) && !$aCacheForm['is_recurring']) {
$aVals['recurring_period'] = 0;
$aVals['recurring_cost'] = null;
}
}
$aVals['cost'] = serialize($aVals['cost']);
if ($bIsRecurring) {
$aVals['recurring_cost'] = serialize($aVals['recurring_cost']);
}
if (!empty($_FILES['image']['name'])) {
$aImage = Phpfox_File::instance()->load('image', array('jpg', 'gif', 'png'));
if ($aImage === false) {
return false;
}
}
$aVals['title'] = $this->preParse()->convert($aVals['title']);
$aVals['description'] = $this->preParse()->convert($aVals['description']);
$aVals['background_color'] = Phpfox::getLib('parse.input')->clean($aVals['background_color']);
if ($iUpdateId !== null) {
$iId = $iUpdateId;
$this->database()->update($this->_sTable, $aVals, 'package_id = ' . (int) $iUpdateId);
} else {
$iLastOrderId = $this->database()->select('ordering')->from($this->_sTable)->order('ordering DESC')->execute('getSlaveField');
$aVals['ordering'] = $iLastOrderId + 1;
$iId = $this->database()->insert($this->_sTable, $aVals);
}
if (!empty($_FILES['image']['name']) && ($sFileName = Phpfox_File::instance()->upload('image', Phpfox::getParam('subscribe.dir_image'), $iId))) {
$this->database()->update($this->_sTable, array('image_path' => $sFileName, 'server_id' => Phpfox_Request::instance()->getServer('PHPFOX_SERVER_ID')), 'package_id = ' . (int) $iId);
Phpfox_Image::instance()->createThumbnail(Phpfox::getParam('subscribe.dir_image') . sprintf($sFileName, ''), Phpfox::getParam('subscribe.dir_image') . sprintf($sFileName, '_120'), 120, 120);
unlink(Phpfox::getParam('subscribe.dir_image') . sprintf($sFileName, ''));
}
return $iId;
}