当前位置: 首页>>代码示例>>PHP>>正文


PHP Space::model方法代码示例

本文整理汇总了PHP中Space::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Space::model方法的具体用法?PHP Space::model怎么用?PHP Space::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Space的用法示例。


在下文中一共展示了Space::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionAssignAllMembers

 public function actionAssignAllMembers($args)
 {
     if (!isset($args[0])) {
         print "Error: Space guid parameter required!\n\n";
         print $this->getHelp();
         return;
     }
     $space = Space::model()->findByAttributes(array('guid' => $args[0]));
     if ($space == null) {
         print "Error: Space not found! Check guid!\n\n";
         return;
     }
     $countMembers = 0;
     $countAssigns = 0;
     foreach (User::model()->findAllByAttributes(array('status' => User::STATUS_ENABLED)) as $user) {
         if ($space->isMember($user->id)) {
             #print "Already Member!";
             $countMembers++;
         } else {
             print "Add member " . $user->displayName . "\n";
             Yii::app()->user->setId($user->id);
             $space->addMember($user->id);
             $countAssigns++;
         }
     }
     print "\nAdded " . $countAssigns . " new members to space " . $space->name . "\n";
 }
开发者ID:alefernie,项目名称:intranet,代码行数:27,代码来源:SpaceCliTool.php

示例2: run

 /**
  * Runs the Widget
  */
 public function run()
 {
     // Possible Security Flaw: Check type!
     $type = $this->activity->type;
     $underlyingObject = $this->activity->getUnderlyingObject();
     // Try to figure out wallEntryId of this activity
     $wallEntryId = 0;
     if ($underlyingObject != null) {
         if ($underlyingObject instanceof HActiveRecordContent || $underlyingObject instanceof HActiveRecordContentAddon) {
             $wallEntryId = $underlyingObject->content->getFirstWallEntryId();
         }
     }
     // When element is assigned to a workspace, assign variable
     $workspace = null;
     if ($this->activity->content->space_id != "") {
         $workspace = Space::model()->findByPk($this->activity->content->space_id);
     }
     // User that fired the activity
     $user = $this->activity->content->user;
     if ($user == null) {
         Yii::log("Skipping activity without valid user", "warning");
         return;
     }
     // Dertermine View
     $view = "";
     if ($this->activity->module == "") {
         $view = 'application.modules_core.activity.views.activities.' . $this->activity->type;
     } else {
         $view = $this->activity->module . '.views.activities.' . $this->activity->type;
     }
     // Activity Layout can access it
     $this->wallEntryId = $wallEntryId;
     $this->render($view, array('activity' => $this->activity, 'wallEntryId' => $wallEntryId, 'user' => $user, 'target' => $underlyingObject, 'workspace' => $workspace));
 }
开发者ID:alefernie,项目名称:intranet,代码行数:37,代码来源:ActivityWidget.php

示例3: run

 /**
  * Executes the widgets
  */
 public function run()
 {
     $statsCountSpaces = Space::model()->count();
     $statsCountSpacesHidden = Space::model()->countByAttributes(array('visibility' => Space::VISIBILITY_NONE));
     $statsSpaceMostMembers = Space::model()->find('id = (SELECT space_id  FROM space_membership GROUP BY space_id ORDER BY count(*) DESC LIMIT 1)');
     // Render widgets view
     $this->render('spaceStats', array('statsSpaceMostMembers' => $statsSpaceMostMembers, 'statsCountSpaces' => $statsCountSpaces, 'statsCountSpacesHidden' => $statsCountSpacesHidden));
 }
开发者ID:skapl,项目名称:design,代码行数:11,代码来源:SpaceStatisticsWidget.php

示例4: onSearchRebuild

 /**
  * On rebuild of the search index, rebuild all space records
  *
  * @param type $event
  */
 public static function onSearchRebuild($event)
 {
     foreach (Space::model()->findAll() as $obj) {
         if ($obj->visibility != Space::VISIBILITY_NONE) {
             HSearch::getInstance()->addModel($obj);
         }
         print "s";
     }
 }
开发者ID:alefernie,项目名称:intranet,代码行数:14,代码来源:SpaceModule.php

示例5: run

 /**
  * Executes the widgets
  */
 public function run()
 {
     $criteria = new CDbCriteria();
     $criteria->join = 'LEFT JOIN space_membership ON t.id=space_membership.space_id AND space_membership.user_id=:userId';
     $criteria->condition = 't.visibility != :visibilityNone OR space_membership.status = :statusMember';
     $criteria->params = array(':userId' => Yii::app()->user->id, ':visibilityNone' => Space::VISIBILITY_NONE, ':statusMember' => SpaceMembership::STATUS_MEMBER);
     $newSpaces = Space::model()->active()->recently(10)->findAll($criteria);
     $this->render('newSpaces', array('newSpaces' => $newSpaces, 'showMoreButton' => $this->showMoreButton));
 }
开发者ID:skapl,项目名称:design,代码行数:12,代码来源:NewSpacesWidget.php

示例6: actionIndex

 /**
  * Returns a List of Users
  */
 public function actionIndex()
 {
     Yii::import('admin.forms.*');
     $form = new BasicSettingsForm();
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'basic-settings-form') {
         echo CActiveForm::validate($form);
         Yii::app()->end();
     }
     if (isset($_POST['BasicSettingsForm'])) {
         $_POST['BasicSettingsForm'] = Yii::app()->input->stripClean($_POST['BasicSettingsForm']);
         $form->attributes = $_POST['BasicSettingsForm'];
         if ($form->validate()) {
             HSetting::Set('name', $form->name);
             HSetting::Set('baseUrl', $form->baseUrl);
             HSetting::Set('defaultLanguage', $form->defaultLanguage);
             HSetting::Set('enable', $form->tour, 'tour');
             $spaceGuids = explode(",", $form->defaultSpaceGuid);
             // Remove Old Default Spaces
             foreach (Space::model()->findAllByAttributes(array('auto_add_new_members' => 1)) as $space) {
                 if (!in_array($space->guid, $spaceGuids)) {
                     $space->auto_add_new_members = 0;
                     $space->save();
                 }
             }
             // Add new Default Spaces
             foreach ($spaceGuids as $spaceGuid) {
                 $space = Space::model()->findByAttributes(array('guid' => $spaceGuid));
                 if ($space != null && $space->auto_add_new_members != 1) {
                     $space->auto_add_new_members = 1;
                     $space->save();
                 }
             }
             // set flash message
             Yii::app()->user->setFlash('data-saved', Yii::t('AdminModule.controllers_SettingController', 'Saved'));
             $this->redirect(Yii::app()->createUrl('//admin/setting/index'));
         }
     } else {
         $form->name = HSetting::Get('name');
         $form->baseUrl = HSetting::Get('baseUrl');
         $form->defaultLanguage = HSetting::Get('defaultLanguage');
         $form->tour = HSetting::Get('enable', 'tour');
         $form->defaultSpaceGuid = "";
         foreach (Space::model()->findAllByAttributes(array('auto_add_new_members' => 1)) as $defaultSpace) {
             $form->defaultSpaceGuid .= $defaultSpace->guid . ",";
         }
     }
     $this->render('index', array('model' => $form));
     /*
      Yii::app()->interceptor->preattachEventHandler('SuperAdminNavigationWidget', 'onInit', function($event) {
      $event->sender->addItem(array(
      'label' => 'Item Dynamic Inject Test',
      'url' => Yii::app()->createUrl('')
      ));
      });
     */
 }
开发者ID:ahdail,项目名称:humhub,代码行数:59,代码来源:SettingController.php

示例7: testGet

 public function testGet()
 {
     $this->assertEquals(SpaceSetting::Get(1, 'globalSetting', 'core'), 'xyz');
     $this->assertEquals(SpaceSetting::Get(1, 'globalSetting'), 'xyz');
     $this->assertEquals(SpaceSetting::Get(1, 'moduleSetting', 'someModule'), 'zyx');
     $space = Space::model()->findByPk(1);
     $this->assertEquals($space->getSetting('globalSetting', 'core'), 'xyz');
     $this->assertEquals($space->getSetting('globalSetting'), 'xyz');
     $this->assertEquals($space->getSetting('moduleSetting', 'someModule'), 'zyx');
 }
开发者ID:alefernie,项目名称:intranet,代码行数:10,代码来源:SpaceSettingTest.php

示例8: testGetFollowers

 public function testGetFollowers()
 {
     $space = Space::model()->findByPk(3);
     $space->follow(1);
     $space->follow(2);
     $space->follow(3);
     $users = $space->getFollowers();
     $userIds = array_map(create_function('$user', 'return $user->id;'), $users);
     sort($userIds);
     $this->assertEquals(array(1, 2, 3), $userIds);
 }
开发者ID:alefernie,项目名称:intranet,代码行数:11,代码来源:HFollowableBehaviorTest.php

示例9: actionSearchJson

 /**
  * Returns a workspace list by json
  *
  * It can be filtered by by keyword.
  */
 public function actionSearchJson()
 {
     $keyword = Yii::app()->request->getParam('keyword', "");
     // guid of user/workspace
     $page = (int) Yii::app()->request->getParam('page', 1);
     // current page (pagination)
     $limit = (int) Yii::app()->request->getParam('limit', HSetting::Get('paginationSize'));
     // current page (pagination)
     $keyword = Yii::app()->input->stripClean($keyword);
     $hitCount = 0;
     $query = "model:Space ";
     if (strlen($keyword) > 2) {
         // Include Keyword
         if (strpos($keyword, "@") === false) {
             $keyword = str_replace(".", "", $keyword);
             $query .= "AND (title:" . $keyword . "* OR tags:" . $keyword . "*)";
         }
     }
     //, $limit, $page
     $hits = new ArrayObject(HSearch::getInstance()->Find($query));
     $hitCount = count($hits);
     // Limit Hits
     $hits = new LimitIterator($hits->getIterator(), ($page - 1) * $limit, $limit);
     $json = array();
     #$json['totalHits'] = $hitCount;
     #$json['limit'] = $limit;
     #$results = array();
     foreach ($hits as $hit) {
         $doc = $hit->getDocument();
         $model = $doc->getField("model")->value;
         if ($model == "Space") {
             $workspaceId = $doc->getField('pk')->value;
             $workspace = Space::model()->findByPk($workspaceId);
             if ($workspace != null) {
                 $wsInfo = array();
                 $wsInfo['guid'] = $workspace->guid;
                 $wsInfo['title'] = CHtml::encode($workspace->name);
                 $wsInfo['tags'] = CHtml::encode($workspace->tags);
                 $wsInfo['image'] = $workspace->getProfileImage()->getUrl();
                 $wsInfo['link'] = $workspace->getUrl();
                 #$results[] = $wsInfo;
                 $json[] = $wsInfo;
             } else {
                 Yii::log("Could not load workspace with id " . $userId . " from search index!", CLogger::LEVEL_ERROR);
             }
         } else {
             Yii::log("Got no workspace hit from search index!", CLogger::LEVEL_ERROR);
         }
     }
     #$json['results'] = $results;
     print CJSON::encode($json);
     Yii::app()->end();
 }
开发者ID:alefernie,项目名称:intranet,代码行数:58,代码来源:BrowseController.php

示例10: run

 /**
  * Executes the widgets
  */
 public function run()
 {
     $criteria = new CDbCriteria();
     $criteria->join = 'LEFT JOIN space_membership ON t.id=space_membership.space_id AND space_membership.user_id=:userId';
     $criteria->condition = 't.visibility != :visibilityNone OR space_membership.status = :statusMember';
     $criteria->params = array(':userId' => Yii::app()->user->id, ':visibilityNone' => Space::VISIBILITY_NONE, ':statusMember' => SpaceMembership::STATUS_MEMBER);
     $newSpaces = Space::model()->active()->recently(10)->findAll($criteria);
     $statsCountSpaces = Space::model()->count();
     $statsCountSpacesHidden = Space::model()->countByAttributes(array('visibility' => Space::VISIBILITY_NONE));
     $statsSpaceMostMembers = Space::model()->find('id = (SELECT space_id  FROM space_membership GROUP BY space_id ORDER BY count(*) DESC LIMIT 1)');
     // Render widgets view
     $this->render('spaceStats', array('newSpaces' => $newSpaces, 'statsSpaceMostMembers' => $statsSpaceMostMembers, 'statsCountSpaces' => $statsCountSpaces, 'statsCountSpacesHidden' => $statsCountSpacesHidden));
 }
开发者ID:alefernie,项目名称:intranet,代码行数:16,代码来源:SpaceStatisticsWidget.php

示例11: checkSpaceGuid

 /**
  * This validator function checks the defaultSpaceGuid.
  *
  * @param type $attribute
  * @param type $params
  */
 public function checkSpaceGuid($attribute, $params)
 {
     if ($this->defaultSpaceGuid != "") {
         foreach (explode(',', $this->defaultSpaceGuid) as $spaceGuid) {
             if ($spaceGuid != "") {
                 $space = Space::model()->findByAttributes(array('guid' => $spaceGuid));
                 if ($space == null) {
                     $this->addError($attribute, Yii::t('AdminModule.forms_BasicSettingsForm', "Invalid space"));
                 }
             }
         }
     }
 }
开发者ID:ahdail,项目名称:humhub,代码行数:19,代码来源:BasicSettingsForm.php

示例12: actionBasic

 /**
  * Returns a List of Users
  */
 public function actionBasic()
 {
     Yii::import('admin.forms.*');
     $form = new BasicSettingsForm();
     $form->name = HSetting::Get('name');
     $form->baseUrl = HSetting::Get('baseUrl');
     $form->defaultLanguage = HSetting::Get('defaultLanguage');
     $form->dashboardShowProfilePostForm = HSetting::Get('showProfilePostForm', 'dashboard');
     $form->tour = HSetting::Get('enable', 'tour');
     $form->defaultSpaceGuid = "";
     foreach (Space::model()->findAllByAttributes(array('auto_add_new_members' => 1)) as $defaultSpace) {
         $form->defaultSpaceGuid .= $defaultSpace->guid . ",";
     }
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'basic-settings-form') {
         echo CActiveForm::validate($form);
         Yii::app()->end();
     }
     if (isset($_POST['BasicSettingsForm'])) {
         $_POST['BasicSettingsForm'] = Yii::app()->input->stripClean($_POST['BasicSettingsForm']);
         $form->attributes = $_POST['BasicSettingsForm'];
         if ($form->validate()) {
             HSetting::Set('name', $form->name);
             HSetting::Set('baseUrl', $form->baseUrl);
             HSetting::Set('defaultLanguage', $form->defaultLanguage);
             HSetting::Set('enable', $form->tour, 'tour');
             HSetting::Set('showProfilePostForm', $form->dashboardShowProfilePostForm, 'dashboard');
             $spaceGuids = explode(",", $form->defaultSpaceGuid);
             // Remove Old Default Spaces
             foreach (Space::model()->findAllByAttributes(array('auto_add_new_members' => 1)) as $space) {
                 if (!in_array($space->guid, $spaceGuids)) {
                     $space->auto_add_new_members = 0;
                     $space->save();
                 }
             }
             // Add new Default Spaces
             foreach ($spaceGuids as $spaceGuid) {
                 $space = Space::model()->findByAttributes(array('guid' => $spaceGuid));
                 if ($space != null && $space->auto_add_new_members != 1) {
                     $space->auto_add_new_members = 1;
                     $space->save();
                 }
             }
             // set flash message
             Yii::app()->user->setFlash('data-saved', Yii::t('AdminModule.controllers_SettingController', 'Saved'));
             $this->redirect(Yii::app()->createUrl('//admin/setting/basic'));
         }
     }
     $this->render('basic', array('model' => $form));
 }
开发者ID:skapl,项目名称:design,代码行数:52,代码来源:SettingController.php

示例13: onCronHourlyRun

 /**
  * Recalculate user and content reputation every hour
  * Only do this in spaces where reputation module is enabled
  *
  * @param $event
  * @throws CException
  */
 public static function onCronHourlyRun($event)
 {
     Yii::import('application.modules.reputation.models.*');
     $cron = $event->sender;
     foreach (Space::model()->findAll() as $space) {
         if ($space->isModuleEnabled('reputation')) {
             $cronJobEnabled = SpaceSetting::Get($space->id, 'cron_job', 'reputation', ReputationBase::DEFAULT_CRON_JOB);
             if ($cronJobEnabled) {
                 print "- Recalculating reputation for space: {$space->id}  {$space->name}\n";
                 ReputationUser::model()->updateUserReputation($space, true);
                 ReputationContent::model()->updateContentReputation($space, true);
             }
         }
     }
 }
开发者ID:plantoschka,项目名称:humhub-modules-reputation,代码行数:22,代码来源:ReputationModule.php

示例14: actionSpaces

 /**
  * Page which shows all current workspaces
  */
 public function actionSpaces()
 {
     $pageSize = 5;
     $criteria = new CDbCriteria();
     $criteria->condition = 'visibility != ' . Space::VISIBILITY_NONE;
     $criteria->order = 'id DESC';
     //$criteria->params = array (':id'=>$id);
     $workspaceCount = Space::model()->count($criteria);
     $pages = new CPagination($workspaceCount);
     $pages->setPageSize($pageSize);
     $pages->applyLimit($criteria);
     // the trick is here!
     $workspaces = Space::model()->findAll($criteria);
     $this->render('workspaces', array('workspaces' => $workspaces, 'pages' => $pages, 'workspaceCount' => $workspaceCount, 'pageSize' => $pageSize));
 }
开发者ID:alefernie,项目名称:intranet,代码行数:18,代码来源:DashboardController.php

示例15: __construct

 public function __construct()
 {
     if (!isset($this->id)) {
         $this->id = '';
     }
     if (!isset($this->icon)) {
         $this->icon = '';
     }
     if (!isset($this->targets)) {
         $this->targets = false;
     }
     if (!isset($this->notemplate)) {
         $this->notemplate = 0;
     }
     if (Yii::app()->request->getParam('sguid') != '' && ($this->space = Space::model()->findByPk(Yii::app()->request->getParam('sguid'))) == null) {
         $this->space = false;
     }
     return parent::__construct();
 }
开发者ID:bendroid,项目名称:humhub-modules-custom-pages-extended,代码行数:19,代码来源:CustomStackWidget.php


注:本文中的Space::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。