/** * saves the request token * * @author Matthias Pfefferle * @param OAuthToken $pToken * @param Community $pCommunity * @return AuthToken */ public static function saveToken($pToken, $pCommunity) { $lToken = new OauthRequestToken(); $lToken->setTokenKey($pToken->key); $lToken->setTokenSecret($pToken->secret); $lToken->setCommunityId($pCommunity->getId()); $lToken->save(); return $lToken; }
public function actionAdmin() { $model = new Community('search'); $model->unsetAttributes(); if (isset($_GET['Community'])) { $model->setAttributes($_GET['Community']); } $this->render('admin', array('model' => $model)); }
public function getScheduleByThisDayAndMemberInCommunity(Community $community, $year, $month, $day) { $day = sprintf('%04d-%02d-%02d', (int) $year, (int) $month, (int) $day); $memberIds = array(); foreach ($community->getMembers() as $member) { $memberIds[] = $member->id; } if (!$memberIds) { return array(); } return $this->createQuery()->select('id, title')->where('start_date <= ?', $day)->andWhere('end_date >= ?', $day)->andWhere('public_flag = ?', PluginScheduleTable::PUBLIC_FLAG_SNS)->andWhere('member_id IN (' . implode(', ', $memberIds) . ')')->execute(); }
function __construct() { parent::__construct(); $this->table = 'file'; $this->id_column = 'id'; $this->deleted_activated = 'id IS NOT NULL '; }
public function insert(SimpleXMLElement $xml) { $member = Doctrine::getTable('Member')->find($this->getMemberIdByUrl((string) $xml->author->uri)); if (!$member) { return false; } $community = new Community(); $community->setName((string) $xml->title); $community->save(); $admin = new CommunityMember(); $admin->setPosition('admin'); $admin->setMember($member); $admin->setCommunity($community); $admin->save(); $config = new CommunityConfig(); $config->setName('description'); $config->setValue((string) $xml->content); $config->setCommunity($community); $config->save(); return $community; }
protected function executeTransaction($conn, $arguments = array(), $options = array()) { $n = (int) $options['number']; $adminMember = Doctrine::getTable('Member')->find($options['admin-member']); if (!$adminMember) { throw new Exception("not found member: " . $options['admin-member']); } $communityCategory = Doctrine::getTable('CommunityCategory')->find($options['category']); if (!$communityCategory) { throw new Exception("not found category: " . $options['category']); } for ($i = 0; $i < $n; $i++) { $community = new Community(); $community->setName('dummy'); $community->setCommunityCategory($communityCategory); $community->save(); $community->setName(sprintf($options['name-format'], $community->getId())); $community->save(); $configData = array(array('description', $community->getName())); if (version_compare(OPENPNE_VERSION, '3.5.0-dev', '>=')) { // new version $configData[] = array('register_policy', 'open'); } else { // old version $configData[] = array('register_poricy', 'open'); } foreach ($configData as $config) { $communityConfig = new CommunityConfig(); $communityConfig->setCommunity($community); $communityConfig->setName($config[0]); $communityConfig->setValue($config[1]); $communityConfig->save(); } $communityMember = new CommunityMember(); $communityMember->setCommunity($community); $communityMember->setMember($adminMember); if (version_compare(OPENPNE_VERSION, '3.3.1-dev', '>=')) { $communityMember->addPosition('admin'); } else { $communityMember->setPosition('admin'); } $communityMember->save(); $this->logSection('community+', $community->getName()); } }
public function marker($args = array()) { $data = array(); $args = $this->setArgs($args); $communities = Community::getCommunities(); $data['communities'] = CommunityReport::getReportGroupsByDate($args); $data['communities'] = $this->formatGroups($data['communities']); // format communities so that each community lists the reported types and their colors in array form $data['communitygroups'] = $this->formatMarkers($communities, $data['communities']); $data['reports'] = Report::getReportByDate($args); $data['reports'] = $this->formatReports($data['reports']); return $data; }
public static function sendNotificationMail(Community $community, $id, $type, $nickname, $subject, $body) { if (version_compare(OPENPNE_VERSION, '3.6beta1-dev', '<')) { return null; } sfContext::getInstance()->getConfiguration()->loadHelpers(array('opUtil')); $params = array('community_name' => $community->getName(), 'wiki_name' => $subject, 'nickname' => $nickname, 'body' => $body); $rs = Doctrine::getTable('CommunityMember')->createQuery()->where('community_id = ?', array($community->getId()))->andWhere('is_receive_mail_pc = ? OR is_receive_mail_mobile = ?', array(true, true))->execute(array(), Doctrine::HYDRATE_ON_DEMAND); foreach ($rs as $r) { $member = $r->getMember(); $memberPcAddress = $member->getConfig('pc_address'); $memberMobileAddress = $member->getConfig('mobile_address'); $from = self::getPostMailAddress('mail_community_' . $type . '_comment_create', array('id' => $id, 'hash' => $member->getMailAddressHash())); if ($r->getIsReceiveMailPc() && $memberPcAddress) { $params['url'] = app_url_for('pc_frontend', '@community' . ucfirst($type) . '_show?id=' . $id, true); opMailSend::sendTemplateMail('notifyCommunityPosting', $memberPcAddress, $from, $params); } if ($r->getIsReceiveMailMobile() && $memberMobileAddress) { $params['url'] = app_url_for('mobile_frontend', '@community' . ucfirst($type) . '_show?id=' . $id, true); opMailSend::sendTemplateMail('notifyCommunityPosting', $memberMobileAddress, $from, $params); } } }
public static function createOrUpdate($udid) { $type = 'update'; $userid = UserIdentity::getuserid($udid); $community = Community::model()->findByAttributes(array('user_id' => $userid)); if (!$community) { $community = new Community(); $type = 'create'; } $userlocate = User::model()->get_locate()->findByPk($userid); $community->user_id = $userid; $community->begin_time = self::getTime(); $community->lng = $userlocate->y; $community->lat = $userlocate->x; $community->type = 1; $community->communityid = uniqid("", true); $community->des = $userlocate->nickname . "的漂流伞"; if (!$community->save()) { Yii::log(CVarDumper::dumpAsString($community->errors), 'error', 'Community new save error'); } else { BDLbs::createOrUpdate(intval($community->id), $community->des, $community->des, $community->lat, $community->lng, $type); return true; } }
private function createCluster($memberNum, $offset) { $memberIds = array(); $members = Doctrine::getTable('Member')->createQuery()->select('id')->where('is_active != 0')->limit($memberNum)->offset($memberNum * $offset)->execute(); for ($i = 0; $i < $memberNum; ++$i) { $community = new Community(); $community->setName('dummy'); $community->save(); $community->setName(sprintf('dummy%d community', $community->getId())); $community->save(); $configData = array( array('description', $community->getName()), array('topic_authority', 'public'), array('public_flag', 'public'), array('register_policy', 'open') ); foreach ($configData as $config) { $communityConfig = new CommunityConfig(); $communityConfig->setCommunity($community); $communityConfig->setName($config[0]); $communityConfig->setValue($config[1]); $communityConfig->save(); $communityConfig->free(); } for ($j = 0; $j < $memberNum; ++$j) { $communityMember = new CommunityMember(); $communityMember->setCommunity($community); $communityMember->setMember($members[$j]); if (0 == $j) { $communityMember->addPosition('admin'); } $communityMember->save(); } } }
<?php $this->breadcrumbs = array(Community::label(2), Yii::t('app', 'Index')); $this->menu = array(array('label' => Yii::t('app', 'Create') . ' ' . Community::label(), 'url' => array('create')), array('label' => Yii::t('app', 'Manage') . ' ' . Community::label(2), 'url' => array('admin'))); ?> <h1><?php echo GxHtml::encode(Community::label(2)); ?> </h1> <?php $this->widget('zii.widgets.CListView', array('dataProvider' => $dataProvider, 'itemView' => '_view'));
function __construct() { parent::__construct(); $this->table = 'api_session'; $this->load->model('Author'); }
<?php $this->breadcrumbs = array($model->label(2) => array('index'), Yii::t('app', 'Manage')); $this->menu = array(array('label' => Yii::t('app', 'List') . ' ' . $model->label(2), 'url' => array('index')), array('label' => Yii::t('app', 'Create') . ' ' . $model->label(), 'url' => array('create'))); Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('beneficiary-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <h1><?php echo Yii::t('app', 'Manage') . ' ' . GxHtml::encode($model->label(2)); ?> </h1> <p> You may optionally enter a comparison operator (<, <=, >, >=, <> or =) at the beginning of each of your search values to specify how the comparison should be done. </p> <?php echo GxHtml::link(Yii::t('app', 'Advanced Search'), '#', array('class' => 'search-button')); ?> <div class="search-form"> <?php $this->renderPartial('_search', array('model' => $model)); ?> </div><!-- search-form --> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'beneficiary-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id', 'create_date', 'update_date', 'registration_code', array('name' => 'status_id', 'value' => 'GxHtml::valueEx($data->status)', 'filter' => GxHtml::listDataEx(BeneficiaryStatus::model()->findAllAttributes(null, true))), array('name' => 'neighborhood_id', 'value' => 'GxHtml::valueEx($data->neighborhood)', 'filter' => GxHtml::listDataEx(Community::model()->findAllAttributes(null, true))), array('class' => 'CButtonColumn'))));
<?php $this->breadcrumbs = array($model->label(2) => array('index'), Yii::t('app', 'Manage')); $this->menu = array(array('label' => Yii::t('app', 'List') . ' ' . $model->label(2), 'url' => array('index')), array('label' => Yii::t('app', 'Create') . ' ' . $model->label(), 'url' => array('create'))); Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('subdistribution-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <h1><?php echo Yii::t('app', 'Manage') . ' ' . GxHtml::encode($model->label(2)); ?> </h1> <p> You may optionally enter a comparison operator (<, <=, >, >=, <> or =) at the beginning of each of your search values to specify how the comparison should be done. </p> <?php echo GxHtml::link(Yii::t('app', 'Advanced Search'), '#', array('class' => 'search-button')); ?> <div class="search-form"> <?php $this->renderPartial('_search', array('model' => $model)); ?> </div><!-- search-form --> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'subdistribution-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id', 'code', 'start_date', 'end_date', array('name' => 'region_id', 'value' => 'GxHtml::valueEx($data->region)', 'filter' => GxHtml::listDataEx(Community::model()->findAllAttributes(null, true))), array('name' => 'distribution_id', 'value' => 'GxHtml::valueEx($data->distribution)', 'filter' => GxHtml::listDataEx(Distribution::model()->findAllAttributes(null, true))), array('class' => 'CButtonColumn'))));
public function getForums() { $this->controller->get(\Community::model(), $this); }
/** * Get Community by name. * * @param string $name * @return Community|null */ public static function getCommunityByName($name) { $community = Community::where('name', '=', $name)->first(); return $community; }
function __construct() { parent::__construct(); $this->table = 'users'; $this->deleted_activated = 'id IS NOT NULL '; }
<?php echo $form->labelEx($model, 'status_id'); ?> <?php echo $form->dropDownList($model, 'status_id', GxHtml::listDataEx(BeneficiaryStatus::model()->findAllAttributes(null, true))); ?> <?php echo $form->error($model, 'status_id'); ?> </div><!-- row --> <div class="row"> <?php echo $form->labelEx($model, 'neighborhood_id'); ?> <?php echo $form->dropDownList($model, 'neighborhood_id', GxHtml::listDataEx(Community::model()->findAllAttributes(null, true))); ?> <?php echo $form->error($model, 'neighborhood_id'); ?> </div><!-- row --> <div class="row"> <?php echo $form->labelEx($model, 'deleted_at'); ?> <?php echo $form->textField($model, 'deleted_at'); ?> <?php echo $form->error($model, 'deleted_at'); ?>
echo $form->textField($model, 'en_name', array('maxlength' => 255)); ?> <?php echo $form->error($model, 'en_name'); ?> </div><!-- row --> <div class="row"> <?php echo $form->labelEx($model, 'district_id'); ?> <?php echo $form->dropDownList($model, 'district_id', GxHtml::listDataEx(District::model()->findAllAttributes(null, true))); ?> <?php echo $form->error($model, 'district_id'); ?> </div><!-- row --> <label><?php echo GxHtml::encode($model->getRelationLabel('communities')); ?> </label> <?php echo $form->checkBoxList($model, 'communities', GxHtml::encodeEx(GxHtml::listDataEx(Community::model()->findAllAttributes(null, true)), false, true)); ?> <?php echo GxHtml::submitButton(Yii::t('app', 'Save')); $this->endWidget(); ?> </div><!-- form -->
function __construct() { parent::__construct(); $this->table = 'vipercharts'; }
function __construct() { parent::__construct(); $this->table = 'thread'; $this->search_ignore = array('the', 'are', 'and', 'but', 'does', 'etc', 'from'); }
function __construct() { parent::__construct(); $this->table = 'meta_dataset'; $this->deleted_activated = null; }
public function populationMap() { $communities = Community::with('subdistrict')->get(); //test with limit ->take(5) return View::make('communities.populationMap', compact('communities')); }
<div class="row"> <?php echo $form->label($model, 'status_id'); ?> <?php echo $form->dropDownList($model, 'status_id', GxHtml::listDataEx(BeneficiaryStatus::model()->findAllAttributes(null, true)), array('prompt' => Yii::t('app', 'All'))); ?> </div> <div class="row"> <?php echo $form->label($model, 'neighborhood_id'); ?> <?php echo $form->dropDownList($model, 'neighborhood_id', GxHtml::listDataEx(Community::model()->findAllAttributes(null, true)), array('prompt' => Yii::t('app', 'All'))); ?> </div> <div class="row"> <?php echo $form->label($model, 'deleted_at'); ?> <?php echo $form->textField($model, 'deleted_at'); ?> </div> <div class="row"> <?php echo $form->label($model, 'remote_image');
public function actionImport() { $model = new Beneficiary('search'); $model->unsetAttributes(); $result = new BeneficiaryImportResult(); $count_inserted = 0; $count_updated = 0; if (isset($_FILES) && !empty($_FILES)) { move_uploaded_file($_FILES['UploadFileName']['tmp_name'], Yii::app()->params['IMPORT_PATH'] . $_FILES['UploadFileName']['name']); Yii::import('application.extensions.phpexcel.Classes.PHPExcel', true); $objReader = new PHPExcel_Reader_Excel5(); $objPHPExcel = $objReader->load(Yii::app()->params['IMPORT_PATH'] . $_FILES['UploadFileName']['name']); $objWorksheet = $objPHPExcel->getActiveSheet(); $highestRow = $objWorksheet->getHighestRow(); // e.g. 10 $highestColumn = $objWorksheet->getHighestColumn(); // e.g 'F' $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); // e.g. 5 $criteria = new CDbCriteria(); $criteria->addCondition('name="Active"'); // created Status for vouchers $status = BeneficiaryStatus::model()->find($criteria); $inserted_arr = []; $updated_arr = []; for ($row = 2; $row <= $highestRow; ++$row) { $criteria = new CDbCriteria(); $criteria->addCondition('registration_code="' . $objWorksheet->getCellByColumnAndRow(0, $row)->getValue() . '"'); // created Status for vouchers $beneficiary = Beneficiary::model()->find($criteria); $insert = 0; if (!$beneficiary) { $beneficiary = new Beneficiary(); $insert = 1; $count_inserted++; //$result->set_count_inserted($result->get_count_inserted()++); } else { $count_updated++; } //$result->set_count_updated($result->get_count_updated()++); $communitycriteria = new CDbCriteria(); $communitycriteria->addCondition('en_name="' . $objWorksheet->getCellByColumnAndRow(6, $row)->getValue() . '"'); $community = Community::model()->find($communitycriteria); $beneficiary->registration_code = $objWorksheet->getCellByColumnAndRow(0, $row)->getValue(); $beneficiary->ar_name = $objWorksheet->getCellByColumnAndRow(1, $row)->getValue() ? $objWorksheet->getCellByColumnAndRow(1, $row)->getValue() : $beneficiary->ar_name; $beneficiary->en_name = $objWorksheet->getCellByColumnAndRow(2, $row)->getValue() ? $objWorksheet->getCellByColumnAndRow(2, $row)->getValue() : $beneficiary->en_name; $beneficiary->family_member = $objWorksheet->getCellByColumnAndRow(3, $row)->getValue() ? $objWorksheet->getCellByColumnAndRow(3, $row)->getValue() : $beneficiary->family_member; $beneficiary->main_income_source = $objWorksheet->getCellByColumnAndRow(4, $row)->getValue() ? $objWorksheet->getCellByColumnAndRow(4, $row)->getValue() : $beneficiary->main_income_source; $beneficiary->combine_household = $objWorksheet->getCellByColumnAndRow(5, $row)->getValue() ? $objWorksheet->getCellByColumnAndRow(5, $row)->getValue() : $beneficiary->combine_household; $beneficiary->phone_number = $objWorksheet->getCellByColumnAndRow(7, $row)->getValue() ? $objWorksheet->getCellByColumnAndRow(7, $row)->getValue() : $beneficiary->phone_number; $beneficiary->neighborhood_id = $objWorksheet->getCellByColumnAndRow(6, $row)->getValue() ? $community->id : $beneficiary->neighborhood_id; $beneficiary->status_id = $status->id; $beneficiary->save(); if ($insert) { array_push($inserted_arr, $beneficiary->registration_code); } else { array_push($updated_arr, $beneficiary->registration_code); } } } else { $result->set_error('No File Selected'); } $result->set_count_inserted($count_inserted); $result->set_count_updated($count_updated); $result->set_record_inserted($inserted_arr); $result->set_record_updated($updated_arr); return $this->sendAjaxResponse($result); }
function __construct() { parent::__construct(); $this->table = 'category'; }
/** * Wrapper function for findByIdOrHandle * * @param string $id * @param array $options * @param string $outputFormat * @param string $inputFormat * @return \MIMAS\Service\Jorum\Item $item */ public static function find($id = '', $options = array(), $outputFormat = '', $inputFormat) { $community = new Community($outputFormat, $inputFormat); return $community->findByIdOrHandle($id, $options); }