コード例 #1
9
ファイル: peering3.php プロジェクト: nivertech/zguide
function client_thread($self)
{
    $context = new ZMQContext();
    $client = new ZMQSocket($context, ZMQ::SOCKET_REQ);
    $endpoint = sprintf("ipc://%s-localfe.ipc", $self);
    $client->connect($endpoint);
    $monitor = new ZMQSocket($context, ZMQ::SOCKET_PUSH);
    $endpoint = sprintf("ipc://%s-monitor.ipc", $self);
    $monitor->connect($endpoint);
    $readable = $writeable = array();
    while (true) {
        sleep(mt_rand(0, 4));
        $burst = mt_rand(1, 14);
        while ($burst--) {
            //  Send request with random hex ID
            $task_id = sprintf("%04X", mt_rand(0, 10000));
            $client->send($task_id);
            //  Wait max ten seconds for a reply, then complain
            $poll = new ZMQPoll();
            $poll->add($client, ZMQ::POLL_IN);
            $events = $poll->poll($readable, $writeable, 10 * 1000000);
            if ($events > 0) {
                foreach ($readable as $socket) {
                    $zmsg = new Zmsg($socket);
                    $zmsg->recv();
                    //  Worker is supposed to answer us with our task id
                    assert($zmsg->body() == $task_id);
                }
            } else {
                $monitor->send(sprintf("E: CLIENT EXIT - lost task %s", $task_id));
                exit;
            }
        }
    }
}
コード例 #2
0
ファイル: Arborize.php プロジェクト: Jaaviieer/PrograWeb
 public static function arborize($tokens, $config, $context)
 {
     $definition = $config->getHTMLDefinition();
     $parent = new HTMLPurifier_Token_Start($definition->info_parent);
     $stack = array($parent->toNode());
     foreach ($tokens as $token) {
         $token->skip = null;
         // [MUT]
         $token->carryover = null;
         // [MUT]
         if ($token instanceof HTMLPurifier_Token_End) {
             $token->start = null;
             // [MUT]
             $r = array_pop($stack);
             assert($r->name === $token->name);
             assert(empty($token->attr));
             $r->endCol = $token->col;
             $r->endLine = $token->line;
             $r->endArmor = $token->armor;
             continue;
         }
         $node = $token->toNode();
         $stack[count($stack) - 1]->children[] = $node;
         if ($token instanceof HTMLPurifier_Token_Start) {
             $stack[] = $node;
         }
     }
     assert(count($stack) == 1);
     return $stack[0];
 }
コード例 #3
0
 /**
  * Handle a submission element
  * @param $node DOMElement
  * @return array Array of Representation objects
  */
 function handleElement($node)
 {
     $deployment = $this->getDeployment();
     $context = $deployment->getContext();
     $submission = $deployment->getSubmission();
     assert(is_a($submission, 'Submission'));
     // Create the data object
     $representationDao = Application::getRepresentationDAO();
     $representation = $representationDao->newDataObject();
     $representation->setSubmissionId($submission->getId());
     // Handle metadata in subelements.  Look for the 'name' and 'seq' elements.
     // All other elements are handled by subclasses.
     for ($n = $node->firstChild; $n !== null; $n = $n->nextSibling) {
         if (is_a($n, 'DOMElement')) {
             switch ($n->tagName) {
                 case 'name':
                     $representation->setName($n->textContent, $n->getAttribute('locale'));
                     break;
                 case 'seq':
                     $representation->setSeq($n->textContent);
                     break;
             }
         }
     }
     return $representation;
     // database insert is handled by sub class.
 }
コード例 #4
0
 public function __construct($username, $krbpwd)
 {
     assert($username != null);
     assert($krbpwd != null);
     $this->username = $username;
     $this->krbpwd = $krbpwd;
 }
コード例 #5
0
 /**
  * This implementation assumes an element that is a
  * Filter. It will display the filter name and information
  * about filter parameters (if any).
  * @see GridCellProvider::getTemplateVarsFromRowColumn()
  * @param $row GridRow
  * @param $column GridColumn
  * @return array
  */
 function getTemplateVarsFromRowColumn(&$row, $column)
 {
     $filter =& $row->getData();
     assert(is_a($filter, 'Filter'));
     switch ($column->getId()) {
         case 'settings':
             $label = '';
             foreach ($filter->getSettings() as $filterSetting) {
                 $settingData = $filter->getData($filterSetting->getName());
                 if (is_a($filterSetting, 'BooleanFilterSetting')) {
                     if ($settingData) {
                         if (!empty($label)) {
                             $label .= ' | ';
                         }
                         $label .= __($filterSetting->getDisplayName());
                     }
                 } else {
                     if (!empty($settingData)) {
                         if (!empty($label)) {
                             $label .= ' | ';
                         }
                         $label .= __($filterSetting->getDisplayName()) . ': ' . $settingData;
                     }
                 }
             }
             break;
         default:
             $label = $filter->getData($column->getId());
     }
     return array('label' => $label);
 }
コード例 #6
0
 public function actionSubscribeContacts($marketingListId, $id, $type, $page = 1, $subscribedCount = 0, $skippedCount = 0)
 {
     assert('$type === "contact" || $type === "report"');
     if (!in_array($type, array('contact', 'report'))) {
         throw new NotSupportedException();
     }
     $contactIds = array((int) $id);
     if ($type === 'report') {
         $attributeName = null;
         $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType('reportResultsListPageSize', get_class($this->getModule()));
         $reportDataProvider = MarketingListMembersUtil::makeReportDataProviderAndResolveAttributeName($id, $pageSize, $attributeName);
         $contactIds = MarketingListMembersUtil::getContactIdsByReportDataProviderAndAttributeName($reportDataProvider, $attributeName);
         $pageCount = $reportDataProvider->getPagination()->getPageCount();
         $subscriberInformation = $this->addNewSubscribers($marketingListId, $contactIds);
         if ($pageCount == $page || $pageCount == 0) {
             $subscriberInformation = array('subscribedCount' => $subscribedCount + $subscriberInformation['subscribedCount'], 'skippedCount' => $skippedCount + $subscriberInformation['skippedCount']);
             $message = $this->renderCompleteMessageBySubscriberInformation($subscriberInformation);
             echo CJSON::encode(array('message' => $message, 'type' => 'message'));
         } else {
             $percentageComplete = round($page / $pageCount, 2) * 100 . ' %';
             $message = Zurmo::t('MarketingListsModule', 'Processing: {percentageComplete} complete', array('{percentageComplete}' => $percentageComplete));
             echo CJSON::encode(array('message' => $message, 'type' => 'message', 'nextPage' => $page + 1, 'subscribedCount' => $subscribedCount + $subscriberInformation['subscribedCount'], 'skippedCount' => $skippedCount + $subscriberInformation['skippedCount']));
         }
     } else {
         $subscriberInformation = $this->addNewSubscribers($marketingListId, $contactIds, MarketingListMember::SCENARIO_MANUAL_CHANGE);
         $message = $this->renderCompleteMessageBySubscriberInformation($subscriberInformation);
         echo CJSON::encode(array('message' => $message, 'type' => 'message'));
     }
 }
コード例 #7
0
 /**
  * Format XML for single DC element.
  * @param $propertyName string
  * @param $value array
  * @param $multilingual boolean optional
  */
 function formatElement($propertyName, $values, $multilingual = false)
 {
     if (!is_array($values)) {
         $values = array($values);
     }
     // Translate the property name to XML syntax.
     $openingElement = str_replace(array('[@', ']'), array(' ', ''), $propertyName);
     $closingElement = String::regexp_replace('/\\[@.*/', '', $propertyName);
     // Create the actual XML entry.
     $response = '';
     foreach ($values as $key => $value) {
         if ($multilingual) {
             $key = str_replace('_', '-', $key);
             assert(is_array($value));
             foreach ($value as $subValue) {
                 if ($key == METADATA_DESCRIPTION_UNKNOWN_LOCALE) {
                     $response .= "\t<{$openingElement}>" . OAIUtils::prepOutput($subValue) . "</{$closingElement}>\n";
                 } else {
                     $response .= "\t<{$openingElement} xml:lang=\"{$key}\">" . OAIUtils::prepOutput($subValue) . "</{$closingElement}>\n";
                 }
             }
         } else {
             assert(is_scalar($value));
             $response .= "\t<{$openingElement}>" . OAIUtils::prepOutput($value) . "</{$closingElement}>\n";
         }
     }
     return $response;
 }
コード例 #8
0
 /**
  * @see DataObjectRequiredPolicy::dataObjectEffect()
  */
 function dataObjectEffect()
 {
     $reviewId = (int) $this->getDataObjectId();
     if (!$reviewId) {
         return AUTHORIZATION_DENY;
     }
     $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO');
     /* @var $reviewAssignmentDao ReviewAssignmentDAO */
     $reviewAssignment = $reviewAssignmentDao->getById($reviewId);
     if (!is_a($reviewAssignment, 'ReviewAssignment')) {
         return AUTHORIZATION_DENY;
     }
     // Ensure that the review assignment actually belongs to the
     // authorized submission.
     $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
     assert(is_a($submission, 'Submission'));
     if ($reviewAssignment->getSubmissionId() != $submission->getId()) {
         AUTHORIZATION_DENY;
     }
     // Ensure that the review assignment is for this workflow stage
     $stageId = $this->getAuthorizedContextObject(ASSOC_TYPE_WORKFLOW_STAGE);
     if ($reviewAssignment->getStageId() != $stageId) {
         return AUTHORIZATION_DENY;
     }
     // Save the review Assignment to the authorization context.
     $this->addAuthorizedContextObject(ASSOC_TYPE_REVIEW_ASSIGNMENT, $reviewAssignment);
     return AUTHORIZATION_PERMIT;
 }
コード例 #9
0
 /**
  * Apply this filter to the request.
  *
  * @param array &$request  The current request
  */
 public function process(&$request)
 {
     assert('is_array($request)');
     assert('array_key_exists("Attributes", $request)');
     $attributes =& $request['Attributes'];
     if (!isset($attributes[$this->scopeAttribute])) {
         return;
     }
     if (!isset($attributes[$this->sourceAttribute])) {
         return;
     }
     if (!isset($attributes[$this->targetAttribute])) {
         $attributes[$this->targetAttribute] = array();
     }
     foreach ($attributes[$this->scopeAttribute] as $scope) {
         if (strpos($scope, '@') !== FALSE) {
             $scope = explode('@', $scope, 2);
             $scope = $scope[1];
         }
         foreach ($attributes[$this->sourceAttribute] as $value) {
             $value = $value . '@' . $scope;
             if (in_array($value, $attributes[$this->targetAttribute], TRUE)) {
                 /* Already present. */
                 continue;
             }
             $attributes[$this->targetAttribute][] = $value;
         }
     }
 }
コード例 #10
0
ファイル: SaeStorage.php プロジェクト: firaga/operation
 public function bGenBrief($sDest, $sBriefTag)
 {
     $sBriefTag = trim($sBriefTag, '.');
     if (0 == strlen($sBriefTag)) {
         return true;
     }
     list($type, $brief) = explode('.', $sBriefTag, 2);
     assert(isset($this->_aBriefConf[$type][$brief]));
     $master = Ko_Tool_Singleton::OInstance('SaeStorage')->read($this->_sDomain, $sDest);
     if (false === $master) {
         return false;
     }
     $sExt = pathinfo($sDest, PATHINFO_EXTENSION);
     $method = $this->_aBriefConf[$type][$brief]['crop'] ? 'VCrop' : 'VResize';
     $slave = Ko_Tool_Image::$method($master, '1.' . $sExt, $this->_aBriefConf[$type][$brief]['width'], $this->_aBriefConf[$type][$brief]['height'], Ko_Tool_Image::FLAG_SRC_BLOB | Ko_Tool_Image::FLAG_DST_BLOB);
     if (false === $slave) {
         return false;
     }
     list($name, $ext) = explode('.', $sDest, 2);
     $ret = Ko_Tool_Singleton::OInstance('SaeStorage')->write($this->_sDomain, $name . '.' . $sBriefTag . '.' . $ext, $slave);
     if (false === $ret) {
         return false;
     }
     return true;
 }
コード例 #11
0
 public static function getTypeByModelUsingValidator($model, $attributeName)
 {
     assert('$model instanceof RedBeanModel || $model instanceof ModelForm ||
                 $model instanceof ConfigurableMetadataModel');
     assert('is_string($attributeName) && $attributeName != ""');
     $validators = $model->getValidators($attributeName);
     foreach ($validators as $validator) {
         switch (get_class($validator)) {
             case 'CBooleanValidator':
                 return 'CheckBox';
             case 'CEmailValidator':
                 return 'Email';
             case 'RedBeanModelTypeValidator':
             case 'TypeValidator':
                 switch ($validator->type) {
                     case 'date':
                         return 'Date';
                     case 'datetime':
                         return 'DateTime';
                     case 'integer':
                         return 'Integer';
                     case 'float':
                         return 'Decimal';
                     case 'time':
                         return 'Time';
                     case 'array':
                         throw new NotSupportedException();
                 }
                 break;
             case 'CUrlValidator':
                 return 'Url';
         }
     }
     return null;
 }
コード例 #12
0
 /**
  * Resolves the class name of a <code>ProviderData</code> child based on the
  * <code>providerId</code> property in the <code>$data</code> object.
  *
  * @param $className the parent class name (should be <code>ProviderData</code>)
  * @param $data the received data object to inspect
  * @param array $options should contain <code>(PropertyBasedClassNameResolver::PROPERTY_ID => ProviderData::PROVIDER_ID)</code> entry
  * @return the <code>ProviderData</code> sub class name according to the given value for <code>ProviderData::PROVIDER_ID</code>
  */
 public function resolve($className, $data, array $options = array())
 {
     assert($className == Stormpath::PROVIDER_DATA, '$className arg should be ' . Stormpath::PROVIDER_DATA);
     if (isset($options[DefaultClassNameResolver::PROPERTY_ID])) {
         $propertyId = $options[DefaultClassNameResolver::PROPERTY_ID];
         $arrData = json_decode(json_encode($data), true);
         if (isset($arrData[$propertyId])) {
             $propertyValue = $arrData[$propertyId];
             switch ($propertyValue) {
                 case GoogleProviderData::PROVIDER_ID:
                     return Stormpath::GOOGLE_PROVIDER_DATA;
                 case FacebookProviderData::PROVIDER_ID:
                     return Stormpath::FACEBOOK_PROVIDER_DATA;
                 case GithubProviderData::PROVIDER_ID:
                     return Stormpath::GITHUB_PROVIDER_DATA;
                 case LinkedInProviderData::PROVIDER_ID:
                     return Stormpath::LINKEDIN_PROVIDER_DATA;
                 default:
                     throw new \InvalidArgumentException('Could not find className for providerId ' . $propertyValue);
             }
         } else {
             throw new \InvalidArgumentException('Property ' . $propertyId . ' is not defined in $data object');
         }
     } else {
         throw new \InvalidArgumentException('Required key ' . DefaultClassNameResolver::PROPERTY_ID . ' not found in $options array');
     }
 }
コード例 #13
0
 /**
  * Extracts variables for a given column from a data element
  * so that they may be assigned to template before rendering.
  * @param $row GridRow
  * @param $column GridColumn
  * @return array
  */
 function getTemplateVarsFromRowColumn($row, $column)
 {
     $element = $row->getData();
     $columnId = $column->getId();
     assert(is_a($element, 'ReviewForm') && !empty($columnId));
     switch ($columnId) {
         case 'name':
             $label = $element->getLocalizedTitle();
             return array('label' => $label);
             break;
         case 'inReview':
             $label = $element->getIncompleteCount();
             return array('label' => $label);
             break;
         case 'completed':
             $label = $element->getCompleteCount();
             return array('label' => $label);
             break;
         case 'active':
             $selected = $element->getActive();
             return array('selected' => $selected);
             break;
         default:
             break;
     }
 }
コード例 #14
0
 /**
  * @param   string $moduleName
  * @param   bool $forceEmptyResults
  * Return an empty listView
  * @return  View
  */
 public function getListView($moduleName, $forceEmptyResults = false)
 {
     assert('is_string($moduleName)');
     $pageSize = $this->pageSize;
     $module = Yii::app()->findModule($moduleName);
     $searchFormClassName = $module::getGlobalSearchFormClassName();
     $modelClassName = $module::getPrimaryModelName();
     $model = new $modelClassName(false);
     $searchForm = new $searchFormClassName($model);
     $sanitizedSearchAttributes = MixedTermSearchUtil::getGlobalSearchAttributeByModuleAndPartialTerm($module, $this->term);
     $metadataAdapter = new SearchDataProviderMetadataAdapter($searchForm, $this->user->id, $sanitizedSearchAttributes);
     $listViewClassName = $module::getPluralCamelCasedName() . 'ForMixedModelsSearchListView';
     $sortAttribute = SearchUtil::resolveSortAttributeFromGetArray($modelClassName);
     $sortDescending = SearchUtil::resolveSortDescendingFromGetArray($modelClassName);
     if ($forceEmptyResults) {
         $dataProviderClass = 'EmptyRedBeanModelDataProvider';
         $emptyText = '';
     } else {
         $dataProviderClass = 'RedBeanModelDataProvider';
         $emptyText = null;
     }
     $dataProvider = RedBeanModelDataProviderUtil::makeDataProvider($metadataAdapter->getAdaptedMetadata(false), $modelClassName, $dataProviderClass, $sortAttribute, $sortDescending, $pageSize, $module->getStateMetadataAdapterClassName());
     $listView = new $listViewClassName('default', $module->getId(), $modelClassName, $dataProvider, GetUtil::resolveSelectedIdsFromGet(), '-' . $moduleName, array('route' => '', 'class' => 'SimpleListLinkPager', 'firstPageLabel' => '<span>first</span>', 'prevPageLabel' => '<span>previous</span>', 'nextPageLabel' => '<span>next</span>', 'lastPageLabel' => '<span>last</span>'));
     $listView->setRowsAreSelectable(false);
     $listView->setEmptyText($emptyText);
     return $listView;
 }
コード例 #15
0
/**
 * Hook to run a cron job.
 *
 * @param array &$croninfo  Output
 */
function sanitycheck_hook_cron(&$croninfo)
{
    assert('is_array($croninfo)');
    assert('array_key_exists("summary", $croninfo)');
    assert('array_key_exists("tag", $croninfo)');
    SimpleSAML_Logger::info('cron [sanitycheck]: Running cron in cron tag [' . $croninfo['tag'] . '] ');
    try {
        $sconfig = SimpleSAML_Configuration::getOptionalConfig('config-sanitycheck.php');
        $cronTag = $sconfig->getString('cron_tag', NULL);
        if ($cronTag === NULL || $cronTag !== $croninfo['tag']) {
            return;
        }
        $info = array();
        $errors = array();
        $hookinfo = array('info' => &$info, 'errors' => &$errors);
        SimpleSAML_Module::callHooks('sanitycheck', $hookinfo);
        if (count($errors) > 0) {
            foreach ($errors as $err) {
                $croninfo['summary'][] = 'Sanitycheck error: ' . $err;
            }
        }
    } catch (Exception $e) {
        $croninfo['summary'][] = 'Error executing sanity check: ' . $e->getMessage();
    }
}
 /**
  * @copydoc PKPHandler::initialize()
  */
 function initialize($request)
 {
     parent::initialize($request);
     // Load user-related translations.
     AppLocale::requireComponents(LOCALE_COMPONENT_PKP_USER, LOCALE_COMPONENT_PKP_MANAGER, LOCALE_COMPONENT_APP_MANAGER);
     // Basic grid configuration.
     $this->setTitle('grid.user.currentUsers');
     // Grid actions.
     $router = $request->getRouter();
     $pluginName = $request->getUserVar('pluginName');
     assert(!empty($pluginName));
     $this->_pluginName = $pluginName;
     $dispatcher = $request->getDispatcher();
     $url = $dispatcher->url($request, ROUTE_PAGE, null, 'manager', 'importexport', array('plugin', $pluginName, 'exportAllUsers'));
     $this->addAction(new LinkAction('exportAllUsers', new RedirectConfirmationModal(__('grid.users.confirmExportAllUsers'), null, $url), __('grid.action.exportAllUsers'), 'export_users'));
     //
     // Grid columns.
     //
     // First Name.
     $cellProvider = new DataObjectGridCellProvider();
     $this->addColumn(new GridColumn('firstName', 'user.firstName', null, null, $cellProvider));
     // Last Name.
     $cellProvider = new DataObjectGridCellProvider();
     $this->addColumn(new GridColumn('lastName', 'user.lastName', null, null, $cellProvider));
     // User name.
     $cellProvider = new DataObjectGridCellProvider();
     $this->addColumn(new GridColumn('username', 'user.username', null, null, $cellProvider));
     // Email.
     $cellProvider = new DataObjectGridCellProvider();
     $this->addColumn(new GridColumn('email', 'user.email', null, null, $cellProvider));
 }
コード例 #17
0
 public static function populateAutoresponder($subject, $textContent, $htmlContent, $fromOperationDurationInterval, $operationType, $enableTracking = false, $marketingList = null)
 {
     assert('is_string($subject)');
     assert('is_string($textContent)');
     assert('is_string($htmlContent) || $htmlContent === null');
     assert('is_int($fromOperationDurationInterval)');
     assert('is_int($operationType)');
     assert('is_bool($enableTracking) || is_int($enableTracking)');
     assert('is_object($marketingList) || $marketingList === null');
     if (empty($marketingList)) {
         $marketingLists = MarketingList::getAll();
         if (!empty($marketingLists)) {
             $marketingList = RandomDataUtil::getRandomValueFromArray($marketingLists);
         }
     }
     $autoresponder = new Autoresponder();
     $autoresponder->subject = $subject;
     $autoresponder->textContent = $textContent;
     $autoresponder->htmlContent = $htmlContent;
     $autoresponder->fromOperationDurationInterval = $fromOperationDurationInterval;
     $autoresponder->fromOperationDurationType = TimeDurationUtil::DURATION_TYPE_DAY;
     $autoresponder->operationType = $operationType;
     $autoresponder->enableTracking = $enableTracking;
     $autoresponder->marketingList = $marketingList;
     return $autoresponder;
 }
コード例 #18
0
 public function __invoke($gatewayName)
 {
     assert(is_string($gatewayName) && strlen(trim($gatewayName)) > 0);
     $controller = $this->getController();
     $sm = $controller->getServiceLocator();
     return $sm->get("GTErrorTracker\\Model\\Gateway\\" . $gatewayName);
 }
コード例 #19
0
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("User")');
     $missions = array();
     foreach (self::getMissionData() as $randomMissionData) {
         $postData = array();
         $mission = new Mission();
         $mission->setScenario('importModel');
         $mission->status = Mission::STATUS_AVAILABLE;
         $mission->owner = $demoDataHelper->getRandomByModelName('User');
         $mission->createdByUser = $mission->owner;
         $mission->description = $randomMissionData['description'];
         $mission->reward = $randomMissionData['reward'];
         //Add some comments
         foreach ($randomMissionData['comments'] as $commentDescription) {
             $comment = new Comment();
             $comment->setScenario('importModel');
             $comment->createdByUser = $demoDataHelper->getRandomByModelName('User');
             $comment->description = $commentDescription;
             $mission->comments->add($comment);
         }
         $mission->addPermissions(Group::getByName(Group::EVERYONE_GROUP_NAME), Permission::READ_WRITE);
         $saved = $mission->save();
         assert('$saved');
         $mission = Mission::getById($mission->id);
         ReadPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($mission, Group::getByName(Group::EVERYONE_GROUP_NAME));
         $mission->save();
         $missions[] = $mission->id;
     }
     $demoDataHelper->setRangeByModelName('Mission', $missions[0], $missions[count($missions) - 1]);
 }
コード例 #20
0
 /**
  * @see MetadataDataObjectAdapter::injectMetadataIntoDataObject()
  * @param $metadataDescription MetadataDescription
  * @param $dataObject MetadataDescription
  * @param $replace boolean whether existing meta-data should be replaced
  * @return DataObject
  */
 function &injectMetadataIntoDataObject(&$metadataDescription, &$dataObject, $replace)
 {
     assert($metadataDescription->getMetadataSchema() == $dataObject->getMetadataSchema());
     $replace = $replace ? METADATA_DESCRIPTION_REPLACE_ALL : METADATA_DESCRIPTION_REPLACE_NOTHING;
     $dataObject->setStatements($metadataDescription->getStatements(), $replace);
     return $dataObject;
 }
コード例 #21
0
 /**
  * @copydoc GridRow::initialize()
  */
 function initialize($request, $template = null)
 {
     parent::initialize($request, $template);
     // Is this a new row or an existing row?
     $plugin =& $this->getData();
     /* @var $plugin Plugin */
     assert(is_a($plugin, 'Plugin'));
     $rowId = $this->getId();
     // Only add row actions if this is an existing row
     if (!is_null($rowId)) {
         $router = $request->getRouter();
         /* @var $router PKPRouter */
         $actionArgs = array_merge(array('plugin' => $plugin->getName()), $this->getRequestArgs());
         if ($this->_canEdit($plugin)) {
             foreach ($plugin->getActions($request, $actionArgs) as $action) {
                 $this->addAction($action);
             }
         }
         // Administrative functions.
         if (in_array(ROLE_ID_SITE_ADMIN, $this->_userRoles)) {
             import('lib.pkp.classes.linkAction.request.RemoteActionConfirmationModal');
             $this->addAction(new LinkAction('delete', new RemoteActionConfirmationModal(__('manager.plugins.deleteConfirm'), __('common.delete'), $router->url($request, null, null, 'deletePlugin', null, $actionArgs), 'modal_delete'), __('common.delete'), 'delete'));
             $this->addAction(new LinkAction('upgrade', new AjaxModal($router->url($request, null, null, 'upgradePlugin', null, $actionArgs), __('manager.plugins.upgrade'), 'modal_upgrade'), __('grid.action.upgrade'), 'upgrade'));
         }
     }
 }
 public function __construct($modelClassName, $modelAttributeName)
 {
     assert($modelClassName == "User");
     // Not Coding Standard
     parent::__construct($modelClassName, $modelAttributeName);
     $this->statusData = UserStatusUtil::getStatusArray();
 }
コード例 #23
0
 protected function makeBuilderPredefinedEmailTemplate($name, $unserializedData, $subject = null, $modelClassName = null, $language = null, $type = null, $isDraft = 0, $textContent = null, $htmlContent = null)
 {
     $emailTemplate = new EmailTemplate();
     $emailTemplate->type = $type;
     //EmailTemplate::TYPE_WORKFLOW;
     $emailTemplate->builtType = EmailTemplate::BUILT_TYPE_BUILDER_TEMPLATE;
     $emailTemplate->isDraft = $isDraft;
     $emailTemplate->modelClassName = $modelClassName;
     $emailTemplate->name = $name;
     if (empty($subject)) {
         $subject = $name;
     }
     $emailTemplate->subject = $subject;
     if (!isset($language)) {
         $language = Yii::app()->languageHelper->getForCurrentUser();
     }
     $emailTemplate->language = $language;
     $emailTemplate->htmlContent = $htmlContent;
     $emailTemplate->textContent = $textContent;
     $emailTemplate->serializedData = CJSON::encode($unserializedData);
     $emailTemplate->addPermissions(Group::getByName(Group::EVERYONE_GROUP_NAME), Permission::READ_WRITE_CHANGE_PERMISSIONS_CHANGE_OWNER);
     $saved = $emailTemplate->save(false);
     if (!$saved) {
         throw new FailedToSaveModelException();
     }
     $emailTemplate = EmailTemplate::getById($emailTemplate->id);
     ReadPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($emailTemplate, Group::getByName(Group::EVERYONE_GROUP_NAME));
     $saved = $emailTemplate->save(false);
     assert('$saved');
 }
コード例 #24
0
ファイル: TodoEx.php プロジェクト: nielsk/otodo
 public function __set($name, $value)
 {
     switch ($name) {
         case 'due':
             $this->due = $value;
             if ($value === null) {
                 unset($this->addons['due']);
             } else {
                 assert($value instanceof DateTime);
                 $this->addons['due'] = $value->format('Y-m-d');
             }
             break;
         case 'recurrent':
             $this->recurrent = $value;
             if ($value === null) {
                 unset($this->addons['recurrent']);
             } else {
                 assert($value instanceof Recurrent);
                 $this->addons['recurrent'] = $value->toString();
             }
             break;
         default:
             parent::__set($name, $value);
             break;
     }
 }
コード例 #25
0
/**
 * Hook to add the simple consenet admin module to the frontpage.
 *
 * @param array &$links  The links on the frontpage, split into sections.
 */
function consentSimpleAdmin_hook_frontpage(&$links)
{
    assert('is_array($links)');
    assert('array_key_exists("links", $links)');
    $links['config'][] = array('href' => SimpleSAML_Module::getModuleURL('consentSimpleAdmin/consentAdmin.php'), 'text' => '{consentSimpleAdmin:consentsimpleadmin:header}');
    $links['config'][] = array('href' => SimpleSAML_Module::getModuleURL('consentSimpleAdmin/consentStats.php'), 'text' => '{consentSimpleAdmin:consentsimpleadmin:headerstats}');
}
コード例 #26
0
 /**
  * Generate service output json format
  * @param ApiResult $result
  */
 public static function generateOutput($result)
 {
     assert('$result instanceof ApiResult');
     $output = $result->convertToArray();
     echo json_encode($output);
     return;
 }
コード例 #27
0
 public function __construct($model, $controllerId, $moduleId, $saveActionId, $urlParameters, $uniquePageId, $uniqueId)
 {
     assert('is_int($uniqueId)');
     assert('$model instanceof Comment');
     parent::__construct($model, $controllerId, $moduleId, $saveActionId, $urlParameters, $uniquePageId);
     $this->uniqueId = $uniqueId;
 }
 function buildChallengesList()
 {
     assert(isset($this->dbConnection));
     $bSuccess = FALSE;
     $stmtQuery = "SELECT idChallenge, challengeType, year, month, status, comments";
     $stmtQuery .= " FROM icaict406a_challenges";
     $stmtQuery .= " ORDER BY year DESC, month DESC";
     if ($stmt = $this->dbConnection->prepare($stmtQuery)) {
         if ($bSuccess = $stmt->execute()) {
             $stmt->bind_result($db_idChallenge, $db_challengeType, $db_year, $db_month, $db_status, $db_comments);
             $bSuccess = TRUE;
             while ($stmt->fetch()) {
                 $objChallengeStruct = new c_challengeStruct();
                 $objChallengeStruct->idChallenge = $db_idChallenge;
                 $objChallengeStruct->challengeType = $db_challengeType;
                 $objChallengeStruct->year = $db_year;
                 $objChallengeStruct->month = $db_month;
                 $objChallengeStruct->status = $db_status;
                 $objChallengeStruct->comments = $db_comments;
                 $this->challenges[] = $objChallengeStruct;
             }
         }
         $stmt->close();
         // Free resultset
     }
     return $bSuccess;
 }
コード例 #29
0
 function __construct($conMan, $am)
 {
     assert($conMan instanceof ConfigManager);
     $this->conMan = $conMan;
     assert($am instanceof AesManager);
     $this->am = $am;
 }
コード例 #30
0
ファイル: Cache.php プロジェクト: sgtsaughter/d8portfolio
 /**
  * Merges arrays of cache tags and removes duplicates.
  *
  * The cache tags array is returned in a format that is valid for
  * \Drupal\Core\Cache\CacheBackendInterface::set().
  *
  * When caching elements, it is necessary to collect all cache tags into a
  * single array, from both the element itself and all child elements. This
  * allows items to be invalidated based on all tags attached to the content
  * they're constituted from.
  *
  * @param array $a
  *    Cache tags array to merge.
  * @param array $b
  *    Cache tags array to merge.
  *
  * @return string[]
  *   The merged array of cache tags.
  */
 public static function mergeTags(array $a = [], array $b = [])
 {
     assert('\\Drupal\\Component\\Assertion\\Inspector::assertAllStrings($a) && \\Drupal\\Component\\Assertion\\Inspector::assertAllStrings($b)', 'Cache tags must be valid strings');
     $cache_tags = array_unique(array_merge($a, $b));
     sort($cache_tags);
     return $cache_tags;
 }