idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
49,100 | public static function isActivationTokenValid ( $ token ) { $ expire = Podium :: getInstance ( ) -> podiumConfig -> get ( 'activation_token_expire' ) ; if ( $ expire === null ) { $ expire = 3 * 24 * 60 * 60 ; } return static :: isTokenValid ( $ token , $ expire ) ; } | Finds out if activation token is valid . |
49,101 | public static function isTokenValid ( $ token , $ expire ) { if ( empty ( $ token ) || empty ( $ expire ) ) { return false ; } $ parts = explode ( '_' , $ token ) ; $ timestamp = ( int ) end ( $ parts ) ; return $ timestamp + ( int ) $ expire >= time ( ) ; } | Finds out if given token type is valid . |
49,102 | public function validateCurrentPassword ( $ attribute ) { if ( ! $ this -> hasErrors ( ) ) { if ( ! $ this -> validatePassword ( $ this -> currentPassword ) ) { $ this -> addError ( $ attribute , Yii :: t ( 'podium/view' , 'Current password is incorrect.' ) ) ; } } } | Validates current password . |
49,103 | public function isMod ( $ userId = null ) { return ( new Query ( ) ) -> from ( Mod :: tableName ( ) ) -> where ( [ 'forum_id' => $ this -> id , 'user_id' => $ userId ] ) -> exists ( ) ; } | Checks if user of given ID is moderator of this forum . |
49,104 | public function searchForMods ( $ params ) { $ query = static :: find ( ) ; $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query , 'pagination' => [ 'defaultPageSize' => 10 , 'forcePageParam' => false ] , ] ) ; $ dataProvider -> sort -> defaultOrder = [ 'name' => SORT_ASC ] ; if ( ! ( $ this -> load ( $ params ) && $ this -> validate ( ) ) ) { return $ dataProvider ; } $ query -> andFilterWhere ( [ 'name' => $ this -> name ] ) ; return $ dataProvider ; } | Searches for forums on admin page . |
49,105 | public function getMods ( ) { $ mods = Podium :: getInstance ( ) -> podiumCache -> getElement ( 'forum.moderators' , $ this -> id ) ; if ( $ mods === false ) { $ mods = [ ] ; $ modteam = User :: find ( ) -> select ( [ 'id' , 'role' ] ) -> where ( [ 'status' => User :: STATUS_ACTIVE , 'role' => [ User :: ROLE_ADMIN , User :: ROLE_MODERATOR ] ] ) ; foreach ( $ modteam -> each ( ) as $ user ) { if ( $ user -> role == User :: ROLE_ADMIN ) { $ mods [ ] = $ user -> id ; continue ; } if ( ( new Query ( ) ) -> from ( Mod :: tableName ( ) ) -> where ( [ 'forum_id' => $ this -> id , 'user_id' => $ user -> id ] ) -> exists ( ) ) { $ mods [ ] = $ user -> id ; } } Podium :: getInstance ( ) -> podiumCache -> setElement ( 'forum.moderators' , $ this -> id , $ mods ) ; } return $ mods ; } | Returns list of moderators for this forum . |
49,106 | public function isMod ( $ userId = null ) { if ( in_array ( $ userId ? : User :: loggedId ( ) , $ this -> getMods ( ) ) ) { return true ; } return false ; } | Checks if user is moderator for this forum . |
49,107 | public function search ( $ categoryId = null , $ onlyVisible = false ) { $ query = static :: find ( ) ; if ( $ categoryId ) { $ query -> andWhere ( [ 'category_id' => $ categoryId ] ) ; } if ( $ onlyVisible ) { $ query -> joinWith ( [ 'category' => function ( $ query ) { $ query -> andWhere ( [ Category :: tableName ( ) . '.visible' => 1 ] ) ; } ] ) ; $ query -> andWhere ( [ static :: tableName ( ) . '.visible' => 1 ] ) ; } $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query ] ) ; $ dataProvider -> sort -> defaultOrder = [ 'sort' => SORT_ASC , 'id' => SORT_ASC ] ; return $ dataProvider ; } | Searches forums . |
49,108 | public static function verify ( $ categoryId = null , $ id = null , $ slug = null , $ guest = true ) { if ( ! is_numeric ( $ categoryId ) || $ categoryId < 1 || ! is_numeric ( $ id ) || $ id < 1 || empty ( $ slug ) ) { return null ; } return static :: find ( ) -> joinWith ( [ 'category' => function ( $ query ) use ( $ guest ) { if ( $ guest ) { $ query -> andWhere ( [ Category :: tableName ( ) . '.visible' => 1 ] ) ; } } ] ) -> where ( [ static :: tableName ( ) . '.id' => $ id , static :: tableName ( ) . '.slug' => $ slug , static :: tableName ( ) . '.category_id' => $ categoryId , ] ) -> limit ( 1 ) -> one ( ) ; } | Returns the verified forum . |
49,109 | public function newOrder ( $ order ) { $ sorter = new Sorter ( ) ; $ sorter -> target = $ this ; $ sorter -> order = $ order ; $ sorter -> query = ( new Query ( ) ) -> from ( static :: tableName ( ) ) -> where ( [ 'and' , [ '!=' , 'id' , $ this -> id ] , [ 'category_id' => $ this -> category_id ] ] ) -> orderBy ( [ 'sort' => SORT_ASC , 'id' => SORT_ASC ] ) -> indexBy ( 'id' ) ; return $ sorter -> run ( ) ; } | Sets new forums order . |
49,110 | protected function addColumn ( $ col , $ type ) { if ( empty ( $ col ) ) { return Yii :: t ( 'podium/flash' , 'Installation aborted! Column name missing.' ) ; } if ( empty ( $ type ) ) { return Yii :: t ( 'podium/flash' , 'Installation aborted! Column type missing.' ) ; } try { $ this -> db -> createCommand ( ) -> addColumn ( $ this -> table , $ col , $ type ) -> execute ( ) ; return $ this -> returnSuccess ( Yii :: t ( 'podium/flash' , 'Table column {name} has been added' , [ 'name' => $ col ] ) ) ; } catch ( Exception $ e ) { return $ this -> returnError ( $ e -> getMessage ( ) , __METHOD__ , Yii :: t ( 'podium/flash' , 'Error during table column {name} adding' , [ 'name' => $ col ] ) ) ; } } | Adds column to database table . |
49,111 | protected function addForeign ( $ key , $ ref , $ col , $ delete = null , $ update = null ) { if ( empty ( $ key ) ) { return Yii :: t ( 'podium/flash' , 'Installation aborted! Foreign key name missing.' ) ; } if ( empty ( $ ref ) ) { return Yii :: t ( 'podium/flash' , 'Installation aborted! Foreign key reference missing.' ) ; } if ( empty ( $ col ) ) { return Yii :: t ( 'podium/flash' , 'Installation aborted! Referenced columns missing.' ) ; } try { $ this -> db -> createCommand ( ) -> addForeignKey ( $ this -> getForeignName ( $ key ) , $ this -> table , $ key , $ this -> getTableName ( $ ref ) , $ col , $ delete , $ update ) -> execute ( ) ; return $ this -> returnSuccess ( Yii :: t ( 'podium/flash' , 'Table foreign key {name} has been added' , [ 'name' => $ this -> getForeignName ( $ key ) ] ) ) ; } catch ( Exception $ e ) { return $ this -> returnError ( $ e -> getMessage ( ) , __METHOD__ , Yii :: t ( 'podium/flash' , 'Error during table foreign key {name} adding' , [ 'name' => $ this -> getForeignName ( $ key ) ] ) ) ; } } | Creates database table foreign key . |
49,112 | protected function addIndex ( $ name , $ cols ) { if ( empty ( $ name ) ) { return Yii :: t ( 'podium/flash' , 'Installation aborted! Index name missing.' ) ; } if ( empty ( $ cols ) ) { return Yii :: t ( 'podium/flash' , 'Installation aborted! Index columns missing.' ) ; } try { $ this -> db -> createCommand ( ) -> createIndex ( $ this -> getIndexName ( $ name ) , $ this -> table , $ cols ) -> execute ( ) ; return $ this -> returnSuccess ( Yii :: t ( 'podium/flash' , 'Table index {name} has been added' , [ 'name' => $ this -> getIndexName ( $ name ) ] ) ) ; } catch ( Exception $ e ) { return $ this -> returnError ( $ e -> getMessage ( ) , __METHOD__ , Yii :: t ( 'podium/flash' , 'Error during table index {name} adding' , [ 'name' => $ this -> getIndexName ( $ name ) ] ) ) ; } } | Creates database table index . |
49,113 | protected function createTable ( $ schema ) { if ( empty ( $ schema ) ) { return Yii :: t ( 'podium/flash' , 'Installation aborted! Database schema missing.' ) ; } try { $ this -> db -> createCommand ( ) -> createTable ( $ this -> table , $ schema , $ this -> tableOptions ) -> execute ( ) ; return $ this -> returnSuccess ( Yii :: t ( 'podium/flash' , 'Table {name} has been created' , [ 'name' => $ this -> rawTable ] ) ) ; } catch ( Exception $ e ) { if ( $ this -> _table != 'log' ) { Yii :: error ( $ e -> getMessage ( ) , __METHOD__ ) ; } return Yii :: t ( 'podium/flash' , 'Error during table {name} creating' , [ 'name' => $ this -> rawTable ] ) . ': ' . Html :: tag ( 'pre' , $ e -> getMessage ( ) ) ; } } | Creates database table . |
49,114 | protected function dropTable ( ) { try { if ( $ this -> db -> schema -> getTableSchema ( $ this -> table , true ) !== null ) { $ this -> db -> createCommand ( ) -> dropTable ( $ this -> table ) -> execute ( ) ; return $ this -> returnWarning ( Yii :: t ( 'podium/flash' , 'Table {name} has been dropped' , [ 'name' => $ this -> rawTable ] ) ) ; } return true ; } catch ( Exception $ e ) { return $ this -> returnError ( $ e -> getMessage ( ) , __METHOD__ , Yii :: t ( 'podium/flash' , 'Error during table {name} dropping' , [ 'name' => $ this -> rawTable ] ) ) ; } } | Drops current database table if it exists . |
49,115 | protected function dropColumn ( $ col ) { if ( empty ( $ col ) ) { return Yii :: t ( 'podium/flash' , 'Installation aborted! Column name missing.' ) ; } try { $ this -> db -> createCommand ( ) -> dropColumn ( $ this -> table , $ col ) -> execute ( ) ; return $ this -> returnWarning ( Yii :: t ( 'podium/flash' , 'Table column {name} has been dropped' , [ 'name' => $ col ] ) ) ; } catch ( Exception $ e ) { return $ this -> returnError ( $ e -> getMessage ( ) , __METHOD__ , Yii :: t ( 'podium/flash' , 'Error during table column {name} dropping' , [ 'name' => $ col ] ) ) ; } } | Drops database table column . |
49,116 | protected function dropForeign ( $ name ) { if ( empty ( $ name ) ) { return Yii :: t ( 'podium/flash' , 'Installation aborted! Foreign key name missing.' ) ; } try { $ this -> db -> createCommand ( ) -> dropForeignKey ( $ this -> getForeignName ( $ name ) , $ this -> table ) -> execute ( ) ; return $ this -> returnWarning ( Yii :: t ( 'podium/flash' , 'Table foreign key {name} has been dropped' , [ 'name' => $ this -> getForeignName ( $ name ) ] ) ) ; } catch ( Exception $ e ) { return $ this -> returnError ( $ e -> getMessage ( ) , __METHOD__ , Yii :: t ( 'podium/flash' , 'Error during table foreign key {name} dropping' , [ 'name' => $ this -> getForeignName ( $ name ) ] ) ) ; } } | Drops database table foreign key . |
49,117 | protected function dropIndex ( $ name ) { if ( empty ( $ name ) ) { return Yii :: t ( 'podium/flash' , 'Installation aborted! Index name missing.' ) ; } try { $ this -> db -> createCommand ( ) -> dropIndex ( $ this -> getIndexName ( $ name ) , $ this -> table ) -> execute ( ) ; return $ this -> returnWarning ( Yii :: t ( 'podium/flash' , 'Table index {name} has been dropped' , [ 'name' => $ this -> getIndexName ( $ name ) ] ) ) ; } catch ( Exception $ e ) { return $ this -> returnError ( $ e -> getMessage ( ) , __METHOD__ , Yii :: t ( 'podium/flash' , 'Error during table index {name} dropping' , [ 'name' => $ this -> getIndexName ( $ name ) ] ) ) ; } } | Drops database table index . |
49,118 | protected function rename ( $ name ) { if ( empty ( $ name ) ) { return Yii :: t ( 'podium/flash' , 'Installation aborted! New table name missing.' ) ; } try { $ this -> db -> createCommand ( ) -> renameTable ( $ this -> table , $ this -> getTableName ( $ name ) ) -> execute ( ) ; return $ this -> returnSuccess ( Yii :: t ( 'podium/flash' , 'Table {name} has been renamed to {new}' , [ 'name' => $ this -> rawTable , 'new' => $ this -> getTableName ( $ name ) ] ) ) ; } catch ( Exception $ e ) { return $ this -> returnError ( $ e -> getMessage ( ) , __METHOD__ , Yii :: t ( 'podium/flash' , 'Error during table {name} renaming to {new}' , [ 'name' => $ this -> rawTable , 'new' => $ this -> getTableName ( $ name ) ] ) ) ; } } | Renames database table . |
49,119 | protected function renameColumn ( $ col , $ name ) { if ( empty ( $ col ) ) { return Yii :: t ( 'podium/flash' , 'Installation aborted! Column name missing.' ) ; } if ( empty ( $ name ) ) { return Yii :: t ( 'podium/flash' , 'Installation aborted! New column name missing.' ) ; } try { $ this -> db -> createCommand ( ) -> renameColumn ( $ this -> table , $ col , $ name ) -> execute ( ) ; return $ this -> returnSuccess ( Yii :: t ( 'podium/flash' , 'Table column {name} has been renamed to {new}' , [ 'name' => $ col , 'new' => $ name ] ) ) ; } catch ( Exception $ e ) { return $ this -> returnError ( $ e -> getMessage ( ) , __METHOD__ , Yii :: t ( 'podium/flash' , 'Error during table column {name} renaming to {new}' , [ 'name' => $ col , 'new' => $ name ] ) ) ; } } | Renames database table column . |
49,120 | public function returnError ( $ exception , $ method , $ message ) { Yii :: error ( $ exception , $ method ) ; return $ message . ':' . Html :: tag ( 'pre' , $ exception ) ; } | Returns error message . Logs error . |
49,121 | public function search ( ) { $ query = static :: find ( ) -> where ( [ 'and' , [ 'is not' , 'post_id' , null ] , [ 'like' , 'word' , $ this -> query ] ] ) -> joinWith ( [ 'posts.author' , 'posts.thread' ] ) ; if ( Podium :: getInstance ( ) -> user -> isGuest ) { $ query -> joinWith ( [ 'posts.forum' => function ( $ q ) { $ q -> where ( [ Forum :: tableName ( ) . '.visible' => 1 ] ) ; } ] ) ; } $ query -> groupBy ( [ 'post_id' , 'word_id' ] ) ; $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query , 'sort' => [ 'defaultOrder' => [ 'thread_id' => SORT_DESC ] , 'attributes' => [ 'thread_id' => [ 'asc' => [ 'thread_id' => SORT_ASC ] , 'desc' => [ 'thread_id' => SORT_DESC ] , 'default' => SORT_DESC , ] , ] ] , ] ) ; return $ dataProvider ; } | Returns data provider for simple search . |
49,122 | public function registerComponents ( ) { $ this -> registerDbConnection ( ) ; $ this -> registerIdentity ( ) ; $ this -> registerCache ( ) ; $ this -> registerAuthorization ( ) ; $ this -> registerFormatter ( ) ; $ this -> registerTranslations ( ) ; } | Registers required components . |
49,123 | public function getComponent ( $ name ) { $ configurationName = $ name . 'Component' ; if ( is_string ( $ this -> module -> $ configurationName ) ) { return Yii :: $ app -> get ( $ this -> module -> $ configurationName ) ; } return $ this -> module -> get ( 'podium_' . $ name ) ; } | Returns instance of component of given name . |
49,124 | public function registerAuthorization ( ) { if ( $ this -> module -> rbacComponent !== true && ! is_string ( $ this -> module -> rbacComponent ) && ! is_array ( $ this -> module -> rbacComponent ) ) { throw new InvalidConfigException ( 'Invalid value for the rbacComponent parameter.' ) ; } if ( is_string ( $ this -> module -> rbacComponent ) ) { return ; } $ this -> module -> set ( 'podium_rbac' , is_array ( $ this -> module -> rbacComponent ) ? $ this -> module -> rbacComponent : [ 'class' => 'yii\rbac\DbManager' , 'db' => $ this -> module -> db , 'itemTable' => '{{%podium_auth_item}}' , 'itemChildTable' => '{{%podium_auth_item_child}}' , 'assignmentTable' => '{{%podium_auth_assignment}}' , 'ruleTable' => '{{%podium_auth_rule}}' , 'cache' => $ this -> module -> cache ] ) ; } | Registers user authorization . |
49,125 | public function registerFormatter ( ) { if ( $ this -> module -> formatterComponent !== true && ! is_string ( $ this -> module -> formatterComponent ) && ! is_array ( $ this -> module -> formatterComponent ) ) { throw new InvalidConfigException ( 'Invalid value for the formatterComponent parameter.' ) ; } if ( is_string ( $ this -> module -> formatterComponent ) ) { return ; } $ this -> module -> set ( 'podium_formatter' , is_array ( $ this -> module -> formatterComponent ) ? $ this -> module -> formatterComponent : [ 'class' => 'yii\i18n\Formatter' , 'timeZone' => 'UTC' , ] ) ; } | Registers formatter with default time zone . |
49,126 | public function registerIdentity ( ) { if ( $ this -> module -> userComponent !== true && ! is_string ( $ this -> module -> userComponent ) && ! is_array ( $ this -> module -> userComponent ) ) { throw new InvalidConfigException ( 'Invalid value for the userComponent parameter.' ) ; } if ( is_string ( $ this -> module -> userComponent ) ) { return ; } $ this -> module -> set ( 'podium_user' , is_array ( $ this -> module -> userComponent ) ? $ this -> module -> userComponent : [ 'class' => 'bizley\podium\web\User' , 'identityClass' => 'bizley\podium\models\User' , 'enableAutoLogin' => true , 'loginUrl' => $ this -> module -> loginUrl , 'identityCookie' => [ 'name' => 'podium' , 'httpOnly' => true , 'secure' => $ this -> module -> secureIdentityCookie , ] , 'idParam' => '__id_podium' , ] ) ; } | Registers user identity . |
49,127 | public function registerDbConnection ( ) { if ( ! is_string ( $ this -> module -> dbComponent ) && ! is_array ( $ this -> module -> dbComponent ) ) { throw new InvalidConfigException ( 'Invalid value for the dbComponent parameter.' ) ; } if ( is_array ( $ this -> module -> dbComponent ) ) { $ this -> module -> set ( 'podium_db' , $ this -> module -> dbComponent ) ; } } | Registers DB connection . |
49,128 | public function registerCache ( ) { if ( $ this -> module -> cacheComponent !== false && ! is_string ( $ this -> module -> cacheComponent ) && ! is_array ( $ this -> module -> cacheComponent ) ) { throw new InvalidConfigException ( 'Invalid value for the cacheComponent parameter.' ) ; } if ( is_string ( $ this -> module -> cacheComponent ) ) { return ; } $ this -> module -> set ( 'podium_cache' , is_array ( $ this -> module -> cacheComponent ) ? $ this -> module -> cacheComponent : [ 'class' => 'yii\caching\DummyCache' ] ) ; } | Registers cache . |
49,129 | public function search ( ) { $ loggedId = User :: loggedId ( ) ; $ query = Thread :: find ( ) -> joinWith ( [ 'threadView' => function ( $ q ) use ( $ loggedId ) { $ q -> onCondition ( [ 'user_id' => $ loggedId ] ) ; $ q -> andWhere ( [ 'or' , new Expression ( 'new_last_seen < new_post_at' ) , new Expression ( 'edited_last_seen < edited_post_at' ) , [ 'new_last_seen' => null ] , [ 'edited_last_seen' => null ] , ] ) ; } ] , false ) ; $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query , 'pagination' => [ 'defaultPageSize' => 10 , 'forcePageParam' => false ] , ] ) ; $ dataProvider -> sort -> defaultOrder = [ 'edited_post_at' => SORT_ASC , 'id' => SORT_ASC ] ; $ dataProvider -> pagination -> pageSize = Yii :: $ app -> session -> get ( 'per-page' , 20 ) ; return $ dataProvider ; } | Searches for threads with unread posts . |
49,130 | public static function warnings ( ) { return [ 'maintenance' => Yii :: t ( 'podium/flash' , 'Podium is currently in the Maintenance mode. All users without Administrator privileges are redirected to {maintenancePage}. You can switch the mode off at {settingsPage}.' , [ 'maintenancePage' => Html :: a ( Yii :: t ( 'podium/flash' , 'Maintenance page' ) , [ 'forum/maintenance' ] ) , 'settingsPage' => Html :: a ( Yii :: t ( 'podium/flash' , 'Settings page' ) , [ 'admin/settings' ] ) , ] ) , 'email' => Yii :: t ( 'podium/flash' , 'No e-mail address has been set for your account! Go to {link} to add one.' , [ 'link' => Html :: a ( Yii :: t ( 'podium/view' , 'Profile' ) . ' > ' . Yii :: t ( 'podium/view' , 'Account Details' ) , [ 'profile/details' ] ) ] ) , 'old_version' => Yii :: t ( 'podium/flash' , 'It looks like there is a new version of Podium database! {link}' , [ 'link' => Html :: a ( Yii :: t ( 'podium/view' , 'Update Podium' ) , [ 'install/level-up' ] ) ] ) , 'new_version' => Yii :: t ( 'podium/flash' , 'Module version appears to be older than database! Please verify your database.' ) ] ; } | Returns warning messages . |
49,131 | public function maintenanceCheck ( $ action , $ warnings ) { if ( $ this -> module -> podiumConfig -> get ( 'maintenance_mode' ) != '1' ) { return false ; } if ( $ action -> id === 'maintenance' ) { return false ; } if ( $ warnings ) { foreach ( $ warnings as $ warning ) { if ( $ warning === static :: warnings ( ) [ 'maintenance' ] ) { if ( ! User :: can ( Rbac :: ROLE_ADMIN ) ) { return $ this -> redirect ( [ 'forum/maintenance' ] ) ; } return false ; } } } $ this -> warning ( static :: warnings ( ) [ 'maintenance' ] , false ) ; if ( ! User :: can ( Rbac :: ROLE_ADMIN ) ) { return $ this -> redirect ( [ 'forum/maintenance' ] ) ; } return false ; } | Performs maintenance check . |
49,132 | public function emailCheck ( $ warnings ) { if ( $ warnings ) { foreach ( $ warnings as $ warning ) { if ( $ warning === static :: warnings ( ) [ 'email' ] ) { return false ; } } } $ user = User :: findMe ( ) ; if ( $ user && empty ( $ user -> email ) ) { $ this -> warning ( static :: warnings ( ) [ 'email' ] , false ) ; } return false ; } | Performs email check . |
49,133 | public function upgradeCheck ( $ warnings ) { if ( ! User :: can ( Rbac :: ROLE_ADMIN ) ) { return false ; } if ( $ warnings ) { foreach ( $ warnings as $ warning ) { if ( $ warning === static :: warnings ( ) [ 'old_version' ] ) { return false ; } if ( $ warning === static :: warnings ( ) [ 'new_version' ] ) { return false ; } } } $ result = Helper :: compareVersions ( explode ( '.' , $ this -> module -> version ) , explode ( '.' , $ this -> module -> podiumConfig -> get ( 'version' ) ) ) ; if ( $ result === '>' ) { $ this -> warning ( static :: warnings ( ) [ 'old_version' ] , false ) ; } elseif ( $ result === '<' ) { $ this -> warning ( static :: warnings ( ) [ 'new_version' ] , false ) ; } return false ; } | Performs upgrade check . |
49,134 | public function init ( ) { parent :: init ( ) ; try { if ( ! empty ( $ this -> module -> accessChecker ) ) { $ this -> accessType = call_user_func ( $ this -> module -> accessChecker , $ this -> module -> user ) ; } if ( $ this -> accessType === - 1 ) { if ( ! empty ( $ this -> module -> denyCallback ) ) { call_user_func ( $ this -> module -> denyCallback , $ this -> module -> user ) ; return false ; } return $ this -> goHome ( ) ; } if ( ! $ this -> module -> user -> isGuest ) { $ user = User :: findMe ( ) ; if ( $ this -> module -> userComponent !== true && $ this -> accessType === 1 ) { if ( empty ( $ user ) ) { if ( ! User :: createInheritedAccount ( ) ) { throw new InvalidConfigException ( 'There was an error while creating inherited user account. Podium can not run with the current configuration. Please contact administrator about this problem.' ) ; } $ this -> success ( Yii :: t ( 'podium/flash' , 'Hey! Your new forum account has just been automatically created! Go to {link} to complement it.' , [ 'link' => Html :: a ( Yii :: t ( 'podium/view' , 'Profile' ) , [ 'profile/details' ] ) ] ) ) ; } elseif ( ! User :: updateInheritedAccount ( ) ) { throw new InvalidConfigException ( 'There was an error while updating inherited user account. Podium can not run with the current configuration. Please contact administrator about this problem.' ) ; } } if ( $ user && $ user -> status == User :: STATUS_BANNED ) { return $ this -> redirect ( [ 'forum/ban' ] ) ; } if ( $ user && ! empty ( $ user -> meta -> timezone ) ) { $ this -> module -> formatter -> timeZone = $ user -> meta -> timezone ; } } } catch ( Exception $ exc ) { Yii :: $ app -> response -> redirect ( [ $ this -> module -> prepareRoute ( 'install/run' ) ] ) ; } } | Creates inherited user account . Redirects banned user to proper view . Sets user s time zone . |
49,135 | public function getParsedSignature ( ) { if ( Podium :: getInstance ( ) -> podiumConfig -> get ( 'use_wysiwyg' ) == '0' ) { $ parser = new GithubMarkdown ( ) ; $ parser -> html5 = true ; return $ parser -> parse ( $ this -> signature ) ; } return $ this -> signature ; } | Returns signature Markdown - parsed if WYSIWYG editor is switched off . |
49,136 | public function actions ( ) { return [ 'lock' => [ 'class' => 'bizley\podium\actions\ThreadAction' , 'permission' => Rbac :: PERM_LOCK_THREAD , 'boolAttribute' => 'locked' , 'switcher' => 'podiumLock' , 'onMessage' => Yii :: t ( 'podium/flash' , 'Thread has been locked.' ) , 'offMessage' => Yii :: t ( 'podium/flash' , 'Thread has been unlocked.' ) ] , 'pin' => [ 'class' => 'bizley\podium\actions\ThreadAction' , 'permission' => Rbac :: PERM_PIN_THREAD , 'boolAttribute' => 'pinned' , 'switcher' => 'podiumPin' , 'onMessage' => Yii :: t ( 'podium/flash' , 'Thread has been pinned.' ) , 'offMessage' => Yii :: t ( 'podium/flash' , 'Thread has been unpinned.' ) ] , ] ; } | Returns separated thread actions . |
49,137 | public function actionDelete ( $ cid = null , $ fid = null , $ id = null , $ slug = null ) { $ thread = ( new ThreadVerifier ( [ 'categoryId' => $ cid , 'forumId' => $ fid , 'threadId' => $ id , 'threadSlug' => $ slug ] ) ) -> verify ( ) ; if ( empty ( $ thread ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! We can not find the thread you are looking for.' ) ) ; return $ this -> redirect ( [ 'forum/index' ] ) ; } if ( ! User :: can ( Rbac :: PERM_DELETE_THREAD , [ 'item' => $ thread ] ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! You do not have the required permission to perform this action.' ) ) ; return $ this -> redirect ( [ 'forum/index' ] ) ; } $ postData = Yii :: $ app -> request -> post ( 'thread' ) ; if ( $ postData ) { if ( $ postData != $ thread -> id ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! There was an error while deleting the thread.' ) ) ; } else { if ( $ thread -> podiumDelete ( ) ) { $ this -> success ( Yii :: t ( 'podium/flash' , 'Thread has been deleted.' ) ) ; return $ this -> redirect ( [ 'forum/forum' , 'cid' => $ thread -> forum -> category_id , 'id' => $ thread -> forum -> id , 'slug' => $ thread -> forum -> slug ] ) ; } $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! There was an error while deleting the thread.' ) ) ; } } return $ this -> render ( 'delete' , [ 'model' => $ thread ] ) ; } | Deleting the thread of given category ID forum ID own ID and slug . |
49,138 | public function actionNewThread ( $ cid = null , $ fid = null ) { if ( ! User :: can ( Rbac :: PERM_CREATE_THREAD ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! You do not have the required permission to perform this action.' ) ) ; return $ this -> redirect ( [ 'forum/index' ] ) ; } $ forum = Forum :: find ( ) -> where ( [ 'id' => $ fid , 'category_id' => $ cid ] ) -> limit ( 1 ) -> one ( ) ; if ( empty ( $ forum ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! We can not find the forum you are looking for.' ) ) ; return $ this -> redirect ( [ 'forum/index' ] ) ; } $ model = new Thread ( ) ; $ model -> scenario = 'new' ; $ model -> subscribe = 1 ; $ preview = false ; $ postData = Yii :: $ app -> request -> post ( ) ; if ( $ model -> load ( $ postData ) ) { $ model -> posts = 0 ; $ model -> views = 0 ; $ model -> category_id = $ forum -> category -> id ; $ model -> forum_id = $ forum -> id ; $ model -> author_id = User :: loggedId ( ) ; if ( $ model -> validate ( ) ) { if ( isset ( $ postData [ 'preview-button' ] ) ) { $ preview = true ; } else { if ( $ model -> podiumNew ( ) ) { $ this -> success ( Yii :: t ( 'podium/flash' , 'New thread has been created.' ) ) ; return $ this -> redirect ( [ 'forum/thread' , 'cid' => $ forum -> category -> id , 'fid' => $ forum -> id , 'id' => $ model -> id , 'slug' => $ model -> slug ] ) ; } $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! There was an error while creating the thread. Contact administrator about this problem.' ) ) ; } } } return $ this -> render ( 'new-thread' , [ 'preview' => $ preview , 'model' => $ model , 'forum' => $ forum , ] ) ; } | Creating the thread of given category ID and forum ID . |
49,139 | public function isMessageReceiver ( $ userId ) { if ( $ this -> messageReceivers ) { foreach ( $ this -> messageReceivers as $ receiver ) { if ( $ receiver -> receiver_id == $ userId ) { return true ; } } } return false ; } | Checks if user is a message receiver . |
49,140 | public static function tooMany ( $ userId ) { $ sessionKey = 'messages.' . $ userId ; if ( Yii :: $ app -> session -> has ( $ sessionKey ) ) { $ sentAlready = explode ( '|' , Yii :: $ app -> session -> get ( $ sessionKey ) ) ; $ validated = [ ] ; foreach ( $ sentAlready as $ t ) { if ( preg_match ( '/^[0-9]+$/' , $ t ) ) { if ( $ t > time ( ) - self :: SPAM_WAIT * 60 ) { $ validated [ ] = $ t ; } } } Yii :: $ app -> session -> set ( $ sessionKey , implode ( '|' , $ validated ) ) ; if ( count ( $ validated ) >= self :: SPAM_MESSAGES ) { return true ; } } return false ; } | Checks if user sent already more than SPAM_MESSAGES in last SPAM_WAIT minutes . |
49,141 | public function podiumReport ( $ post = null ) { try { if ( empty ( $ post ) ) { throw new Exception ( 'Reported post missing' ) ; } $ logged = User :: loggedId ( ) ; $ this -> sender_id = $ logged ; $ this -> topic = Yii :: t ( 'podium/view' , 'Complaint about the post #{id}' , [ 'id' => $ post -> id ] ) ; if ( Podium :: getInstance ( ) -> podiumConfig -> get ( 'use_wysiwyg' ) == '0' ) { $ this -> content .= "\n\n---\n" . '[' . Yii :: t ( 'podium/view' , 'Direct link to this post' ) . '](' . Url :: to ( [ 'forum/show' , 'id' => $ post -> id ] ) . ')' . "\n\n---\n" . '**' . Yii :: t ( 'podium/view' , 'Post contents' ) . '**' . $ post -> content ; } else { $ this -> content .= '<hr>' . Html :: a ( Yii :: t ( 'podium/view' , 'Direct link to this post' ) , [ 'forum/show' , 'id' => $ post -> id ] ) . '<hr>' . '<p>' . Yii :: t ( 'podium/view' , 'Post contents' ) . '</p>' . '<blockquote>' . $ post -> content . '</blockquote>' ; } $ this -> sender_status = self :: STATUS_DELETED ; if ( ! $ this -> save ( ) ) { throw new Exception ( 'Saving complaint error!' ) ; } $ receivers = [ ] ; $ mods = $ post -> forum -> mods ; $ stamp = time ( ) ; foreach ( $ mods as $ mod ) { if ( $ mod != $ logged ) { $ receivers [ ] = [ $ this -> id , $ mod , self :: STATUS_NEW , $ stamp , $ stamp ] ; } } if ( empty ( $ receivers ) ) { throw new Exception ( 'No one to send report to' ) ; } if ( ! Podium :: getInstance ( ) -> db -> createCommand ( ) -> batchInsert ( MessageReceiver :: tableName ( ) , [ 'message_id' , 'receiver_id' , 'receiver_status' , 'created_at' , 'updated_at' ] , $ receivers ) -> execute ( ) ) { throw new Exception ( 'Reports saving error!' ) ; } Podium :: getInstance ( ) -> podiumCache -> delete ( 'user.newmessages' ) ; Log :: info ( 'Post reported' , $ post -> id , __METHOD__ ) ; return true ; } catch ( Exception $ e ) { Log :: error ( $ e -> getMessage ( ) , null , __METHOD__ ) ; } return false ; } | Performs post report sending to moderators . |
49,142 | public function getParsedContent ( ) { if ( Podium :: getInstance ( ) -> podiumConfig -> get ( 'use_wysiwyg' ) == '0' ) { $ parser = new GithubMarkdown ( ) ; $ parser -> html5 = true ; return $ parser -> parse ( $ this -> content ) ; } return $ this -> content ; } | Returns content Markdown - parsed if WYSIWYG editor is switched off . |
49,143 | public static function clearAfter ( $ what ) { $ cache = new static ; switch ( $ what ) { case 'userDelete' : $ cache -> delete ( 'forum.latestposts' ) ; case 'activate' : $ cache -> delete ( 'members.fieldlist' ) ; $ cache -> delete ( 'forum.memberscount' ) ; break ; case 'categoryDelete' : case 'forumDelete' : case 'threadDelete' : case 'postDelete' : $ cache -> delete ( 'forum.threadscount' ) ; $ cache -> delete ( 'forum.postscount' ) ; $ cache -> delete ( 'user.threadscount' ) ; $ cache -> delete ( 'user.postscount' ) ; $ cache -> delete ( 'forum.latestposts' ) ; break ; case 'threadMove' : case 'postMove' : $ cache -> delete ( 'forum.threadscount' ) ; $ cache -> delete ( 'forum.postscount' ) ; $ cache -> delete ( 'forum.latestposts' ) ; break ; case 'newThread' : $ cache -> delete ( 'forum.threadscount' ) ; $ cache -> deleteElement ( 'user.threadscount' , User :: loggedId ( ) ) ; case 'newPost' : $ cache -> delete ( 'forum.postscount' ) ; $ cache -> delete ( 'forum.latestposts' ) ; $ cache -> deleteElement ( 'user.postscount' , User :: loggedId ( ) ) ; break ; } } | Clears several elements at once . |
49,144 | public function deleteElement ( $ key , $ element ) { $ cache = $ this -> get ( $ key ) ; if ( $ cache !== false && isset ( $ cache [ $ element ] ) ) { unset ( $ cache [ $ element ] ) ; return $ this -> set ( $ key , $ cache ) ; } return true ; } | Deletes the value of element with the specified key from cache array . |
49,145 | public function getElement ( $ key , $ element ) { $ cache = $ this -> get ( $ key ) ; if ( $ cache !== false && isset ( $ cache [ $ element ] ) ) { return $ cache [ $ element ] ; } return false ; } | Retrieves the value of element from array cache with the specified key . |
49,146 | public function set ( $ key , $ value , $ duration = 0 ) { return $ this -> engine -> set ( $ this -> _cachePrefix . $ key , $ value , $ duration ) ; } | Stores the value identified by the key into cache . |
49,147 | public function setElement ( $ key , $ element , $ value , $ duration = 0 ) { $ cache = $ this -> get ( $ key ) ; if ( $ cache === false ) { $ cache = [ ] ; } $ cache [ $ element ] = $ value ; return $ this -> set ( $ key , $ cache , $ duration ) ; } | Stores the value for the element into cache array identified by the key . |
49,148 | public function run ( ) { $ user = $ this -> getUser ( User :: STATUS_REGISTERED ) ; if ( empty ( $ user ) ) { return [ true , Yii :: t ( 'podium/flash' , 'Sorry! We can not find the account with that user name or e-mail address.' ) , false ] ; } $ user -> scenario = 'token' ; $ user -> generateActivationToken ( ) ; if ( ! $ user -> save ( ) ) { return [ true , null , false ] ; } if ( empty ( $ user -> email ) ) { return [ true , Yii :: t ( 'podium/flash' , 'Sorry! There is no e-mail address saved with your account. Contact administrator about reactivating.' ) , true ] ; } if ( ! $ this -> sendReactivationEmail ( $ user ) ) { return [ true , Yii :: t ( 'podium/flash' , 'Sorry! There was some error while sending you the account activation link. Contact administrator about this problem.' ) , true ] ; } return [ false , Yii :: t ( 'podium/flash' , 'The account activation link has been sent to your e-mail address.' ) , true ] ; } | Generates new activation token . |
49,149 | protected function sendReactivationEmail ( User $ user ) { $ forum = Podium :: getInstance ( ) -> podiumConfig -> get ( 'name' ) ; $ email = Content :: fill ( Content :: EMAIL_REACTIVATION ) ; if ( $ email !== false ) { $ link = Url :: to ( [ 'account/activate' , 'token' => $ user -> activation_token ] , true ) ; return Email :: queue ( $ user -> email , str_replace ( '{forum}' , $ forum , $ email -> topic ) , str_replace ( '{forum}' , $ forum , str_replace ( '{link}' , Html :: a ( $ link , $ link ) , $ email -> content ) ) , ! empty ( $ user -> id ) ? $ user -> id : null ) ; } return false ; } | Sends reactivation email . |
49,150 | protected static function addGuest ( $ ip , $ url ) { $ activity = static :: find ( ) -> where ( [ 'ip' => $ ip , 'user_id' => null ] ) -> limit ( 1 ) -> one ( ) ; if ( empty ( $ activity ) ) { $ activity = new static ; $ activity -> ip = $ ip ; } $ activity -> url = $ url ; return $ activity -> save ( ) ; } | Adds guest activity . |
49,151 | protected static function addUser ( $ ip , $ url ) { if ( ! $ user = User :: findMe ( ) ) { return false ; } $ activity = static :: find ( ) -> where ( [ 'user_id' => $ user -> id ] ) -> limit ( 1 ) -> one ( ) ; if ( ! $ activity ) { $ activity = new static ; $ activity -> user_id = $ user -> id ; } $ activity -> username = $ user -> podiumName ; $ activity -> user_role = $ user -> role ; $ activity -> user_slug = $ user -> podiumSlug ; $ activity -> url = $ url ; $ activity -> ip = $ ip ; $ activity -> anonymous = ! empty ( $ user -> meta ) ? $ user -> meta -> anonymous : 0 ; return $ activity -> save ( ) ; } | Adds registered user activity . |
49,152 | public static function add ( ) { try { $ ip = Yii :: $ app -> request -> userIp ; $ url = Yii :: $ app -> request -> url ; if ( empty ( $ ip ) ) { $ ip = '0.0.0.0' ; } if ( Podium :: getInstance ( ) -> user -> isGuest ) { if ( static :: addGuest ( $ ip , $ url ) ) { return true ; } } else { if ( static :: addUser ( $ ip , $ url ) ) { return true ; } } Log :: error ( 'Cannot log user activity' , null , __METHOD__ ) ; } catch ( Exception $ e ) { Log :: error ( $ e -> getMessage ( ) , null , __METHOD__ ) ; } return false ; } | Adds user activity . |
49,153 | public static function deleteUser ( $ id ) { $ activity = static :: find ( ) -> where ( [ 'user_id' => $ id ] ) -> limit ( 1 ) -> one ( ) ; if ( empty ( $ activity ) || ! $ activity -> delete ( ) ) { Log :: error ( 'Cannot delete user activity' , $ id , __METHOD__ ) ; return ; } Podium :: getInstance ( ) -> podiumCache -> delete ( 'forum.lastactive' ) ; } | Deletes user activity . |
49,154 | public static function updateName ( $ id , $ username , $ slug ) { $ activity = static :: find ( ) -> where ( [ 'user_id' => $ id ] ) -> limit ( 1 ) -> one ( ) ; if ( empty ( $ activity ) ) { Log :: error ( 'Cannot update user activity' , $ id , __METHOD__ ) ; return ; } $ activity -> username = $ username ; $ activity -> user_slug = $ slug ; if ( ! $ activity -> save ( ) ) { Log :: error ( 'Cannot update user activity' , $ id , __METHOD__ ) ; return ; } Podium :: getInstance ( ) -> podiumCache -> delete ( 'forum.lastactive' ) ; } | Updates username after change . |
49,155 | public static function updateRole ( $ id , $ role ) { $ activity = static :: find ( ) -> where ( [ 'user_id' => $ id ] ) -> limit ( 1 ) -> one ( ) ; if ( empty ( $ activity ) ) { Log :: error ( 'Cannot update user activity' , $ id , __METHOD__ ) ; return ; } $ activity -> user_role = $ role ; if ( ! $ activity -> save ( ) ) { Log :: error ( 'Cannot update user activity' , $ id , __METHOD__ ) ; return ; } Podium :: getInstance ( ) -> podiumCache -> delete ( 'forum.lastactive' ) ; } | Updates role after change . |
49,156 | public static function lastActive ( ) { $ last = Podium :: getInstance ( ) -> podiumCache -> get ( 'forum.lastactive' ) ; if ( $ last === false ) { $ time = time ( ) - 15 * 60 ; $ last = [ 'count' => static :: find ( ) -> where ( [ '>' , 'updated_at' , $ time ] ) -> count ( ) , 'members' => static :: find ( ) -> where ( [ 'and' , [ '>' , 'updated_at' , $ time ] , [ 'is not' , 'user_id' , null ] , [ 'anonymous' => 0 ] ] ) -> count ( ) , 'anonymous' => static :: find ( ) -> where ( [ 'and' , [ '>' , 'updated_at' , $ time ] , [ 'is not' , 'user_id' , null ] , [ 'anonymous' => 1 ] ] ) -> count ( ) , 'guests' => static :: find ( ) -> where ( [ 'and' , [ '>' , 'updated_at' , $ time ] , [ 'user_id' => null ] ] ) -> count ( ) , 'names' => [ ] , ] ; $ members = static :: find ( ) -> where ( [ 'and' , [ '>' , 'updated_at' , $ time ] , [ 'is not' , 'user_id' , null ] , [ 'anonymous' => 0 ] ] ) ; foreach ( $ members -> each ( ) as $ member ) { $ last [ 'names' ] [ $ member -> user_id ] = [ 'name' => $ member -> username , 'role' => $ member -> user_role , 'slug' => $ member -> user_slug , ] ; } Podium :: getInstance ( ) -> podiumCache -> set ( 'forum.lastactive' , $ last , 60 ) ; } return $ last ; } | Updates tracking . |
49,157 | public static function totalMembers ( ) { $ members = Podium :: getInstance ( ) -> podiumCache -> get ( 'forum.memberscount' ) ; if ( $ members === false ) { $ members = User :: find ( ) -> where ( [ '!=' , 'status' , User :: STATUS_REGISTERED ] ) -> count ( ) ; Podium :: getInstance ( ) -> podiumCache -> set ( 'forum.memberscount' , $ members ) ; } return $ members ; } | Counts number of registered users . |
49,158 | public static function totalPosts ( ) { $ posts = Podium :: getInstance ( ) -> podiumCache -> get ( 'forum.postscount' ) ; if ( $ posts === false ) { $ posts = Post :: find ( ) -> count ( ) ; Podium :: getInstance ( ) -> podiumCache -> set ( 'forum.postscount' , $ posts ) ; } return $ posts ; } | Counts number of created posts . |
49,159 | public static function totalThreads ( ) { $ threads = Podium :: getInstance ( ) -> podiumCache -> get ( 'forum.threadscount' ) ; if ( $ threads === false ) { $ threads = Thread :: find ( ) -> count ( ) ; Podium :: getInstance ( ) -> podiumCache -> set ( 'forum.threadscount' , $ threads ) ; } return $ threads ; } | Counts number of created threads . |
49,160 | public function getVersionSteps ( ) { if ( $ this -> _versionSteps === null ) { $ currentVersion = Yii :: $ app -> session -> get ( self :: SESSION_VERSION , 0 ) ; $ versionSteps = [ ] ; foreach ( $ this -> steps as $ version => $ steps ) { if ( Helper :: compareVersions ( explode ( '.' , $ currentVersion ) , explode ( '.' , $ version ) ) == '<' ) { $ versionSteps += $ steps ; } } $ this -> _versionSteps = $ versionSteps ; } return $ this -> _versionSteps ; } | Returns update steps from next new version . |
49,161 | protected function updateValue ( $ name , $ value ) { if ( empty ( $ name ) ) { return Yii :: t ( 'podium/flash' , 'Installation aborted! Column name missing.' ) ; } if ( $ value === null ) { return Yii :: t ( 'podium/flash' , 'Installation aborted! Column value missing.' ) ; } try { Podium :: getInstance ( ) -> podiumConfig -> set ( $ name , $ value ) ; return $ this -> returnSuccess ( Yii :: t ( 'podium/flash' , 'Config setting {name} has been updated to {value}.' , [ 'name' => $ name , 'value' => $ value , ] ) ) ; } catch ( Exception $ e ) { return $ this -> returnError ( $ e -> getMessage ( ) , __METHOD__ , Yii :: t ( 'podium/flash' , 'Error during configuration updating' ) ) ; } } | Updates database value in config table . |
49,162 | public function run ( ) { $ size = 20 ; $ saved = Yii :: $ app -> session -> get ( 'per-page' ) ; if ( in_array ( $ saved , $ this -> pageSizes ) ) { $ size = $ saved ; } $ selected = Yii :: $ app -> request -> get ( 'per-page' ) ; if ( in_array ( $ selected , $ this -> pageSizes ) ) { $ size = $ selected ; } Yii :: $ app -> session -> set ( 'per-page' , $ size ) ; return Html :: tag ( 'div' , Html :: tag ( 'div' , Html :: label ( Yii :: t ( 'podium/view' , 'Results per page' ) , 'per-page' ) . ' ' . Html :: dropDownList ( 'per-page' , $ size , $ this -> pageSizes , [ 'class' => 'form-control input-sm' , 'id' => 'per-page' ] ) , [ 'class' => 'form-group' ] ) , [ 'class' => 'pull-right form-inline' ] ) . '<br><br>' ; } | Rendering the widget dropdown . Default page size is 20 . |
49,163 | public static function blame ( ) { if ( Yii :: $ app instanceof Application && ! Podium :: getInstance ( ) -> user -> isGuest ) { return User :: loggedId ( ) ; } return null ; } | Returns ID of user responsible for logged action . |
49,164 | public static function error ( $ msg , $ model = null , $ category = 'application' ) { Yii :: error ( [ 'msg' => $ msg , 'model' => $ model , ] , $ category ) ; } | Calls for error log . |
49,165 | public static function info ( $ msg , $ model = null , $ category = 'application' ) { Yii :: info ( [ 'msg' => $ msg , 'model' => $ model , ] , $ category ) ; } | Calls for info log . |
49,166 | public static function warning ( $ msg , $ model = null , $ category = 'application' ) { Yii :: warning ( [ 'msg' => $ msg , 'model' => $ model , ] , $ category ) ; } | Calls for warning log . |
49,167 | public function getFirstNewNotSeen ( ) { return $ this -> hasOne ( Post :: className ( ) , [ 'thread_id' => 'id' ] ) -> where ( [ '>' , 'created_at' , $ this -> userView ? $ this -> userView -> new_last_seen : 0 ] ) -> orderBy ( [ 'id' => SORT_ASC ] ) ; } | First new not seen post relation . |
49,168 | public function getFirstEditedNotSeen ( ) { return $ this -> hasOne ( Post :: className ( ) , [ 'thread_id' => 'id' ] ) -> where ( [ '>' , 'edited_at' , $ this -> userView ? $ this -> userView -> edited_last_seen : 0 ] ) -> orderBy ( [ 'id' => SORT_ASC ] ) ; } | First edited not seen post relation . |
49,169 | public function checkAccess ( ) { if ( YII_ENV === 'test' ) { return true ; } $ ip = Yii :: $ app -> request -> getUserIP ( ) ; foreach ( $ this -> module -> allowedIPs as $ filter ) { if ( $ filter === '*' || $ filter === $ ip || ( ( $ pos = strpos ( $ filter , '*' ) ) !== false && ! strncmp ( $ ip , $ filter , $ pos ) ) ) { return true ; } } echo Yii :: t ( 'podium/view' , 'Access to Podium installation is denied due to IP address restriction.' ) ; Yii :: warning ( 'Access to Podium installation is denied due to IP address restriction. The requested IP is ' . $ ip , __METHOD__ ) ; return false ; } | Checks if user s IP is on the allowed list . |
49,170 | public function actionImport ( ) { $ result = [ 'error' => Yii :: t ( 'podium/view' , 'Error' ) ] ; if ( Yii :: $ app -> request -> isPost ) { $ drop = Yii :: $ app -> request -> post ( 'drop' ) ; if ( $ drop !== null ) { $ installation = new Installation ( ) ; if ( ( is_bool ( $ drop ) && $ drop ) || $ drop === 'true' ) { $ result = $ installation -> nextDrop ( ) ; } else { $ result = $ installation -> nextStep ( ) ; } } } return Json :: encode ( $ result ) ; } | Importing the databases structures . |
49,171 | public function actionRun ( ) { Yii :: $ app -> session -> set ( Installation :: SESSION_KEY , 0 ) ; if ( $ this -> module -> userComponent !== true && empty ( $ this -> module -> adminId ) ) { $ this -> warning ( Yii :: t ( 'podium/flash' , "{userComponent} is set to custom but no administrator ID has been set with {adminId} parameter. Administrator privileges will not be set." , [ 'userComponent' => '$userComponent' , 'adminId' => '$adminId' ] ) ) ; } return $ this -> render ( 'run' , [ 'version' => $ this -> module -> version ] ) ; } | Running the installation . |
49,172 | public function actionUpdate ( ) { $ result = [ 'error' => Yii :: t ( 'podium/view' , 'Error' ) ] ; if ( Yii :: $ app -> request -> isPost ) { $ result = ( new Update ( ) ) -> nextStep ( ) ; } return Json :: encode ( $ result ) ; } | Updating the databases structures . |
49,173 | public function actionLevelUp ( ) { Yii :: $ app -> session -> set ( Update :: SESSION_KEY , 0 ) ; $ error = '' ; $ info = '' ; $ dbVersion = 0 ; $ mdVersion = $ this -> module -> version ; $ dbQuery = ( new Query ( ) ) -> from ( '{{%podium_config}}' ) -> select ( 'value' ) -> where ( [ 'name' => 'version' ] ) -> limit ( 1 ) -> one ( ) ; if ( ! isset ( $ dbQuery [ 'value' ] ) ) { $ error = Yii :: t ( 'podium/flash' , 'Error while checking current database version! Please verify your database.' ) ; } else { $ dbVersion = $ dbQuery [ 'value' ] ; $ result = Helper :: compareVersions ( explode ( '.' , $ mdVersion ) , explode ( '.' , $ dbVersion ) ) ; if ( $ result == '=' ) { $ info = Yii :: t ( 'podium/flash' , 'Module and database versions are the same!' ) ; } elseif ( $ result == '<' ) { $ error = Yii :: t ( 'podium/flash' , 'Module version appears to be older than database! Please verify your database.' ) ; } } Yii :: $ app -> session -> set ( Update :: SESSION_VERSION , $ dbVersion ) ; return $ this -> render ( 'level-up' , [ 'currentVersion' => $ mdVersion , 'dbVersion' => $ dbVersion , 'error' => $ error , 'info' => $ info ] ) ; } | Running the upgrade . |
49,174 | public function search ( ) { $ query = static :: find ( ) ; if ( Podium :: getInstance ( ) -> user -> isGuest ) { $ query -> andWhere ( [ 'visible' => 1 ] ) ; } $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query ] ) ; $ dataProvider -> sort -> defaultOrder = [ 'sort' => SORT_ASC , 'id' => SORT_ASC ] ; return $ dataProvider ; } | Searches users . |
49,175 | public function update ( $ data ) { $ validator = new StringValidator ( ) ; $ validator -> max = 255 ; foreach ( $ data as $ key => $ value ) { if ( ! in_array ( $ key , $ this -> readonly ) && array_key_exists ( $ key , $ this -> settings ) ) { if ( ! $ validator -> validate ( $ value ) ) { return false ; } if ( ! $ this -> config -> set ( $ key , $ value ) ) { return false ; } } } return true ; } | Updates the value of setting . |
49,176 | public function validate ( ) { if ( is_numeric ( $ this -> categoryId ) && $ this -> categoryId >= 1 && is_numeric ( $ this -> forumId ) && $ this -> forumId >= 1 && is_numeric ( $ this -> threadId ) && $ this -> threadId >= 1 && ! empty ( $ this -> threadSlug ) ) { return true ; } return false ; } | Validates parameters . |
49,177 | public function verify ( ) { if ( ! $ this -> validate ( ) ) { return null ; } $ this -> _query = Thread :: find ( ) -> where ( [ Thread :: tableName ( ) . '.id' => $ this -> threadId , Thread :: tableName ( ) . '.slug' => $ this -> threadSlug , Thread :: tableName ( ) . '.forum_id' => $ this -> forumId , Thread :: tableName ( ) . '.category_id' => $ this -> categoryId , ] ) ; if ( Podium :: getInstance ( ) -> user -> isGuest ) { return $ this -> getThreadForGuests ( ) ; } return $ this -> getThreadForMembers ( ) ; } | Returns verified thread . |
49,178 | protected function getThreadForGuests ( ) { return $ this -> _query -> joinWith ( [ 'forum' => function ( $ query ) { $ query -> andWhere ( [ Forum :: tableName ( ) . '.visible' => 1 ] ) -> joinWith ( [ 'category' => function ( $ query ) { $ query -> andWhere ( [ Category :: tableName ( ) . '.visible' => 1 ] ) ; } ] ) ; } ] ) -> limit ( 1 ) -> one ( ) ; } | Returns thread for guests . |
49,179 | public function actionClear ( ) { if ( $ this -> module -> podiumCache -> flush ( ) ) { $ this -> success ( Yii :: t ( 'podium/flash' , 'Cache has been cleared.' ) ) ; } else { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! There was some error while clearing the cache.' ) ) ; } return $ this -> redirect ( [ 'admin/settings' ] ) ; } | Clearing all cache . |
49,180 | public function actionContents ( $ name = '' ) { if ( empty ( $ name ) ) { $ name = Content :: TERMS_AND_CONDS ; } $ model = Content :: fill ( $ name ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) { if ( User :: can ( Rbac :: PERM_CHANGE_SETTINGS ) ) { if ( $ model -> save ( ) ) { $ this -> success ( Yii :: t ( 'podium/flash' , 'Content has been saved.' ) ) ; } else { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! There was some error while saving the content.' ) ) ; } } else { $ this -> error ( Yii :: t ( 'podium/flash' , 'You are not allowed to perform this action.' ) ) ; } return $ this -> refresh ( ) ; } return $ this -> render ( 'contents' , [ 'model' => $ model ] ) ; } | Listing the contents . |
49,181 | public function actionDeleteCategory ( $ id = null ) { $ model = Category :: find ( ) -> where ( [ 'id' => $ id ] ) -> limit ( 1 ) -> one ( ) ; if ( empty ( $ model ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! We can not find Category with this ID.' ) ) ; return $ this -> redirect ( [ 'admin/categories' ] ) ; } if ( $ model -> delete ( ) ) { PodiumCache :: clearAfter ( 'categoryDelete' ) ; Log :: info ( 'Category deleted' , $ model -> id , __METHOD__ ) ; $ this -> success ( Yii :: t ( 'podium/flash' , 'Category has been deleted.' ) ) ; } else { Log :: error ( 'Error while deleting category' , $ model -> id , __METHOD__ ) ; $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! There was some error while deleting the category.' ) ) ; } return $ this -> redirect ( [ 'admin/categories' ] ) ; } | Deleting the category of given ID . |
49,182 | public function actionEditForum ( $ cid = null , $ id = null ) { $ model = Forum :: find ( ) -> where ( [ 'id' => $ id , 'category_id' => $ cid ] ) -> limit ( 1 ) -> one ( ) ; if ( empty ( $ model ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! We can not find Forum with this ID.' ) ) ; return $ this -> redirect ( [ 'admin/forums' , 'cid' => $ cid ] ) ; } if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) { if ( $ model -> save ( ) ) { Log :: info ( 'Forum updated' , $ model -> id , __METHOD__ ) ; $ this -> success ( Yii :: t ( 'podium/flash' , 'Forum has been updated.' ) ) ; return $ this -> refresh ( ) ; } $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! There was an error while updating the forum.' ) ) ; } return $ this -> render ( 'forum' , [ 'model' => $ model , 'forums' => Forum :: find ( ) -> where ( [ 'category_id' => $ cid ] ) -> orderBy ( [ 'sort' => SORT_ASC , 'id' => SORT_ASC ] ) -> all ( ) , 'categories' => Category :: find ( ) -> orderBy ( [ 'sort' => SORT_ASC , 'id' => SORT_ASC ] ) -> all ( ) ] ) ; } | Editing the forum of given ID . |
49,183 | public function actionForums ( $ cid = null ) { $ model = Category :: find ( ) -> where ( [ 'id' => $ cid ] ) -> limit ( 1 ) -> one ( ) ; if ( empty ( $ model ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! We can not find Category with this ID.' ) ) ; return $ this -> redirect ( [ 'admin/categories' ] ) ; } return $ this -> render ( 'forums' , [ 'model' => $ model , 'categories' => Category :: find ( ) -> orderBy ( [ 'sort' => SORT_ASC , 'id' => SORT_ASC ] ) -> all ( ) , 'forums' => Forum :: find ( ) -> where ( [ 'category_id' => $ model -> id ] ) -> orderBy ( [ 'sort' => SORT_ASC , 'id' => SORT_ASC ] ) -> all ( ) ] ) ; } | Listing the forums of given category ID . |
49,184 | public function actionLogs ( ) { $ searchModel = new LogSearch ( ) ; return $ this -> render ( 'logs' , [ 'dataProvider' => $ searchModel -> search ( Yii :: $ app -> request -> get ( ) ) , 'searchModel' => $ searchModel , ] ) ; } | Listing the logs . |
49,185 | public function actionNewCategory ( ) { $ model = new Category ( ) ; $ model -> visible = 1 ; $ model -> sort = 0 ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { Log :: info ( 'Category added' , $ model -> id , __METHOD__ ) ; $ this -> success ( Yii :: t ( 'podium/flash' , 'New category has been created.' ) ) ; return $ this -> redirect ( [ 'admin/categories' ] ) ; } return $ this -> render ( 'category' , [ 'model' => $ model , 'categories' => Category :: find ( ) -> orderBy ( [ 'sort' => SORT_ASC , 'id' => SORT_ASC ] ) -> all ( ) ] ) ; } | Adding new category . |
49,186 | public function actionNewForum ( $ cid = null ) { $ category = Category :: find ( ) -> where ( [ 'id' => $ cid ] ) -> limit ( 1 ) -> one ( ) ; if ( empty ( $ category ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! We can not find Category with this ID.' ) ) ; return $ this -> redirect ( [ 'admin/categories' ] ) ; } $ model = new Forum ( ) ; $ model -> category_id = $ category -> id ; $ model -> visible = 1 ; $ model -> sort = 0 ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { Log :: info ( 'Forum added' , $ model -> id , __METHOD__ ) ; $ this -> success ( Yii :: t ( 'podium/flash' , 'New forum has been created.' ) ) ; return $ this -> redirect ( [ 'admin/forums' , 'cid' => $ category -> id ] ) ; } return $ this -> render ( 'forum' , [ 'model' => $ model , 'forums' => Forum :: find ( ) -> where ( [ 'category_id' => $ category -> id ] ) -> orderBy ( [ 'sort' => SORT_ASC , 'id' => SORT_ASC ] ) -> all ( ) , 'categories' => Category :: find ( ) -> orderBy ( [ 'sort' => SORT_ASC , 'id' => SORT_ASC ] ) -> all ( ) ] ) ; } | Adding new forum . |
49,187 | public function actionSettings ( ) { $ model = new ConfigForm ( ) ; $ data = Yii :: $ app -> request -> post ( 'ConfigForm' ) ; if ( $ data ) { if ( User :: can ( Rbac :: PERM_CHANGE_SETTINGS ) ) { if ( $ model -> update ( $ data ) ) { Log :: info ( 'Settings updated' , null , __METHOD__ ) ; $ this -> success ( Yii :: t ( 'podium/flash' , 'Settings have been updated.' ) ) ; return $ this -> refresh ( ) ; } $ this -> error ( Yii :: t ( 'podium/flash' , "One of the setting's values is too long (255 characters max)." ) ) ; } else { $ this -> error ( Yii :: t ( 'podium/flash' , 'You are not allowed to perform this action.' ) ) ; } } return $ this -> render ( 'settings' , [ 'model' => $ model ] ) ; } | Updating the module configuration . |
49,188 | public function actionSortCategory ( ) { if ( ! Yii :: $ app -> request -> isAjax ) { return $ this -> redirect ( [ 'admin/categories' ] ) ; } if ( ! User :: can ( Rbac :: PERM_UPDATE_CATEGORY ) ) { return Html :: tag ( 'span' , Html :: tag ( 'span' , '' , [ 'class' => 'glyphicon glyphicon-warning-sign' ] ) . ' ' . Yii :: t ( 'podium/view' , 'You are not allowed to perform this action.' ) , [ 'class' => 'text-danger' ] ) ; } $ modelId = Yii :: $ app -> request -> post ( 'id' ) ; $ new = Yii :: $ app -> request -> post ( 'new' ) ; if ( ! is_numeric ( $ modelId ) || ! is_numeric ( $ new ) ) { return Html :: tag ( 'span' , Html :: tag ( 'span' , '' , [ 'class' => 'glyphicon glyphicon-warning-sign' ] ) . ' ' . Yii :: t ( 'podium/view' , 'Sorry! Sorting parameters are wrong.' ) , [ 'class' => 'text-danger' ] ) ; } $ moved = Category :: find ( ) -> where ( [ 'id' => $ modelId ] ) -> limit ( 1 ) -> one ( ) ; if ( empty ( $ moved ) ) { return Html :: tag ( 'span' , Html :: tag ( 'span' , '' , [ 'class' => 'glyphicon glyphicon-warning-sign' ] ) . ' ' . Yii :: t ( 'podium/view' , 'Sorry! We can not find Category with this ID.' ) , [ 'class' => 'text-danger' ] ) ; } if ( $ moved -> newOrder ( ( int ) $ new ) ) { return Html :: tag ( 'span' , Html :: tag ( 'span' , '' , [ 'class' => 'glyphicon glyphicon-ok-circle' ] ) . ' ' . Yii :: t ( 'podium/view' , "New categories' order has been saved." ) , [ 'class' => 'text-success' ] ) ; } return Html :: tag ( 'span' , Html :: tag ( 'span' , '' , [ 'class' => 'glyphicon glyphicon-warning-sign' ] ) . ' ' . Yii :: t ( 'podium/view' , "Sorry! We can not save new categories' order." ) , [ 'class' => 'text-danger' ] ) ; } | Updating the categories order . |
49,189 | public function actionSortForum ( ) { if ( ! Yii :: $ app -> request -> isAjax ) { return $ this -> redirect ( [ 'admin/forums' ] ) ; } if ( ! User :: can ( Rbac :: PERM_UPDATE_FORUM ) ) { return Html :: tag ( 'span' , Html :: tag ( 'span' , '' , [ 'class' => 'glyphicon glyphicon-warning-sign' ] ) . ' ' . Yii :: t ( 'podium/view' , 'You are not allowed to perform this action.' ) , [ 'class' => 'text-danger' ] ) ; } $ modelId = Yii :: $ app -> request -> post ( 'id' ) ; $ modelCategory = Yii :: $ app -> request -> post ( 'category' ) ; $ new = Yii :: $ app -> request -> post ( 'new' ) ; if ( ! is_numeric ( $ modelId ) || ! is_numeric ( $ modelCategory ) || ! is_numeric ( $ new ) ) { return Html :: tag ( 'span' , Html :: tag ( 'span' , '' , [ 'class' => 'glyphicon glyphicon-warning-sign' ] ) . ' ' . Yii :: t ( 'podium/view' , 'Sorry! Sorting parameters are wrong.' ) , [ 'class' => 'text-danger' ] ) ; } $ moved = Forum :: find ( ) -> where ( [ 'id' => $ modelId ] ) -> limit ( 1 ) -> one ( ) ; $ movedCategory = Category :: find ( ) -> where ( [ 'id' => $ modelCategory ] ) -> limit ( 1 ) -> one ( ) ; if ( empty ( $ moved ) || empty ( $ modelCategory ) || $ moved -> category_id != $ movedCategory -> id ) { return Html :: tag ( 'span' , Html :: tag ( 'span' , '' , [ 'class' => 'glyphicon glyphicon-warning-sign' ] ) . ' ' . Yii :: t ( 'podium/view' , 'Sorry! We can not find Forum with this ID.' ) , [ 'class' => 'text-danger' ] ) ; } if ( $ moved -> newOrder ( ( int ) $ new ) ) { return Html :: tag ( 'span' , Html :: tag ( 'span' , '' , [ 'class' => 'glyphicon glyphicon-ok-circle' ] ) . ' ' . Yii :: t ( 'podium/view' , "New forums' order has been saved." ) , [ 'class' => 'text-success' ] ) ; } return Html :: tag ( 'span' , Html :: tag ( 'span' , '' , [ 'class' => 'glyphicon glyphicon-warning-sign' ] ) . ' ' . Yii :: t ( 'podium/view' , "Sorry! We can not save new forums' order." ) , [ 'class' => 'text-danger' ] ) ; } | Updating the forums order . |
49,190 | public function actionInbox ( ) { $ searchModel = new MessageReceiver ( ) ; return $ this -> render ( 'inbox' , [ 'dataProvider' => $ searchModel -> search ( Yii :: $ app -> request -> get ( ) ) , 'searchModel' => $ searchModel ] ) ; } | Listing the messages inbox . |
49,191 | public function actionReply ( $ id = null ) { $ podiumUser = User :: findMe ( ) ; if ( Message :: tooMany ( $ podiumUser -> id ) ) { $ this -> warning ( Yii :: t ( 'podium/flash' , 'You have reached maximum {max_messages, plural, =1{ message} other{ messages}} per {max_minutes, plural, =1{ minute} other{ minutes}} limit. Wait few minutes before sending a new message.' , [ 'max_messages' => Message :: SPAM_MESSAGES , 'max_minutes' => Message :: SPAM_WAIT ] ) ) ; return $ this -> redirect ( [ 'messages/inbox' ] ) ; } $ reply = Message :: find ( ) -> where ( [ Message :: tableName ( ) . '.id' => $ id ] ) -> joinWith ( [ 'messageReceivers' => function ( $ q ) use ( $ podiumUser ) { $ q -> where ( [ 'receiver_id' => $ podiumUser -> id ] ) ; } ] ) -> limit ( 1 ) -> one ( ) ; if ( empty ( $ reply ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! We can not find the message with the given ID.' ) ) ; return $ this -> redirect ( [ 'messages/inbox' ] ) ; } $ model = new Message ( ) ; $ model -> topic = Message :: re ( ) . ' ' . $ reply -> topic ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) { if ( $ model -> validate ( ) ) { if ( ! $ podiumUser -> isIgnoredBy ( $ model -> receiversId [ 0 ] ) ) { $ model -> replyto = $ reply -> id ; if ( $ model -> send ( ) ) { $ this -> success ( Yii :: t ( 'podium/flash' , 'Message has been sent.' ) ) ; return $ this -> redirect ( [ 'messages/inbox' ] ) ; } $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! There was some error while sending your message.' ) ) ; } else { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! This member ignores you so you can not send the message.' ) ) ; } } } $ model -> receiversId = [ $ reply -> sender_id ] ; return $ this -> render ( 'reply' , [ 'model' => $ model , 'reply' => $ reply ] ) ; } | Replying to the message of given ID . |
49,192 | public function actionSent ( ) { $ searchModel = new MessageSearch ( ) ; return $ this -> render ( 'sent' , [ 'dataProvider' => $ searchModel -> search ( Yii :: $ app -> request -> get ( ) ) , 'searchModel' => $ searchModel ] ) ; } | Listing the sent messages . |
49,193 | public function actionViewSent ( $ id = null ) { $ model = Message :: find ( ) -> where ( [ 'and' , [ 'id' => $ id , 'sender_id' => User :: loggedId ( ) ] , [ '!=' , 'sender_status' , Message :: STATUS_DELETED ] ] ) -> limit ( 1 ) -> one ( ) ; if ( empty ( $ model ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! We can not find the message with the given ID.' ) ) ; return $ this -> redirect ( [ 'messages/inbox' ] ) ; } $ model -> markRead ( ) ; return $ this -> render ( 'view' , [ 'model' => $ model , 'type' => 'sent' , 'id' => $ model -> id ] ) ; } | Viewing the sent message of given ID . |
49,194 | public function actionViewReceived ( $ id = null ) { $ model = MessageReceiver :: find ( ) -> where ( [ 'and' , [ 'id' => $ id , 'receiver_id' => User :: loggedId ( ) ] , [ '!=' , 'receiver_status' , MessageReceiver :: STATUS_DELETED ] ] ) -> limit ( 1 ) -> one ( ) ; if ( empty ( $ model ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! We can not find the message with the given ID.' ) ) ; return $ this -> redirect ( [ 'messages/inbox' ] ) ; } $ model -> markRead ( ) ; return $ this -> render ( 'view' , [ 'model' => $ model -> message , 'type' => 'received' , 'id' => $ model -> id ] ) ; } | Viewing the received message of given ID . |
49,195 | public function actionLoad ( ) { if ( ! Yii :: $ app -> request -> isAjax ) { return $ this -> redirect ( [ 'forum/index' ] ) ; } $ result = [ 'messages' => '' , 'more' => 0 ] ; if ( ! Podium :: getInstance ( ) -> user -> isGuest ) { $ loggedId = User :: loggedId ( ) ; $ id = Yii :: $ app -> request -> post ( 'message' ) ; $ message = Message :: find ( ) -> where ( [ 'id' => $ id ] ) -> limit ( 1 ) -> one ( ) ; if ( $ message && ( $ message -> sender_id == $ loggedId || $ message -> isMessageReceiver ( $ loggedId ) ) ) { $ stack = 0 ; $ reply = clone $ message ; while ( $ reply -> reply && $ stack < 5 ) { $ result [ 'more' ] = 0 ; if ( $ reply -> reply -> sender_id == $ loggedId && $ reply -> reply -> sender_status == Message :: STATUS_DELETED ) { $ reply = $ reply -> reply ; continue ; } $ result [ 'messages' ] .= $ this -> renderPartial ( 'load' , [ 'reply' => $ reply ] ) ; $ reply = $ reply -> reply ; if ( $ reply ) { $ result [ 'more' ] = $ reply -> id ; } $ stack ++ ; } } } return Json :: encode ( $ result ) ; } | Loads older messages in thread . |
49,196 | protected function encodePath ( $ path ) { $ a = explode ( '/' , $ path ) ; for ( $ i = 0 ; $ i < count ( $ a ) ; $ i ++ ) { $ a [ $ i ] = rawurlencode ( $ a [ $ i ] ) ; } return implode ( '/' , $ a ) ; } | url encode a path |
49,197 | public function actionAssignRole ( $ idOrEmail , $ role ) { if ( ! $ user = $ this -> findUser ( $ idOrEmail ) ) { return self :: EXIT_CODE_ERROR ; } $ rbac = Podium :: getInstance ( ) -> getRbac ( ) ; if ( ! $ role = $ rbac -> getRole ( $ role ) ) { $ this -> stderr ( 'No such role.' . PHP_EOL ) ; return self :: EXIT_CODE_ERROR ; } if ( strpos ( $ role -> name , 'podium' ) === 0 ) { $ this -> setPodiumUserRole ( $ user , $ role ) ; } else { $ rbac -> assign ( $ role , $ user -> id ) ; } $ this -> stdout ( "user#{$user->id} has role '{$role->name}'" . PHP_EOL ) ; } | Changes forum user role . |
49,198 | public function actionRevokeRole ( $ idOrEmail , $ role ) { if ( ! $ user = $ this -> findUser ( $ idOrEmail ) ) { return self :: EXIT_CODE_ERROR ; } $ rbac = Podium :: getInstance ( ) -> getRbac ( ) ; if ( ! $ role = $ rbac -> getRole ( $ role ) ) { $ this -> stderr ( 'No such role.' . PHP_EOL ) ; return self :: EXIT_CODE_ERROR ; } if ( strpos ( $ role -> name , 'podium' ) === 0 ) { $ defaultPodiumRole = $ rbac -> getRole ( Rbac :: ROLE_USER ) ; $ this -> setPodiumUserRole ( $ user , $ defaultPodiumRole ) ; $ this -> stdout ( "user#{$user->id} has role '{$defaultPodiumRole->name}'" . PHP_EOL ) ; } else { $ rbac -> revoke ( $ role , $ user -> id ) ; $ this -> stdout ( "user#{$user->id} role '{$role->name}' revoked" . PHP_EOL ) ; } } | Revokes specified forum user role and sets default forum user role |
49,199 | public function actionShowRoles ( $ idOrEmail ) { if ( ! $ user = $ this -> findUser ( $ idOrEmail ) ) { return self :: EXIT_CODE_ERROR ; } $ roles = Podium :: getInstance ( ) -> getRbac ( ) -> getRolesByUser ( $ user -> id ) ; print_r ( $ roles ) ; } | Shows user roles |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.