function openfire_authenticate($user, $username, $password)
{
    global $openfire;
    $openfire->of_logInfo("openfire_authenticate 1 " . $username . " " . $password);
    if (!openfire_wants_to_login()) {
        return new WP_Error('user_logged_out', sprintf(__('You are now logged out of Azure AD.', AADSSO), $username));
    }
    // Don't re-authenticate if already authenticated
    if (strrpos($username, "@") == false || is_a($user, 'WP_User')) {
        return $user;
    }
    $openfire->of_logInfo("openfire_authenticate 2 ");
    // Try to find an existing user in WP where the UPN of the current AAD user is
    // (depending on config) the 'login' or 'email' field
    if ($username && $password && $openfire->of_authenticate_365($username, $password)) {
        $user = get_user_by("email", $username);
        if (!is_a($user, 'WP_User')) {
            $openfire->of_logInfo("openfire_authenticate 3");
            // Since the user was authenticated with AAD, but not found in WordPress,
            // need to decide whether to create a new user in WP on-the-fly, or to stop here.
            $openfire->of_logInfo("openfire_authenticate 4");
            $paras = explode("@", $username);
            $userid = $paras[0] . "." . $paras[1];
            $new_user_id = wp_create_user($userid, $password, $username);
            $user = new WP_User($new_user_id);
            $user->set_role('subscriber');
            $first_name = $openfire->of_get_given_name();
            $last_name = $openfire->get_family_name();
            $display_name = $first_name . " " . $last_name;
            wp_update_user(array('ID' => $new_user_id, 'display_name' => $display_name, 'first_name' => $first_name, 'last_name' => $last_name));
        }
    }
    return $user;
}
Example #2
1
 private static function listCommands()
 {
     $commands = array();
     $dir = __DIR__;
     if ($handle = opendir($dir)) {
         while (false !== ($entry = readdir($handle))) {
             if ($entry != "." && $entry != ".." && $entry != "base.php") {
                 $s1 = explode("cli_", $entry);
                 $s2 = explode(".php", $s1[1]);
                 if (sizeof($s2) == 2) {
                     require_once "{$dir}/{$entry}";
                     $command = $s2[0];
                     $className = "cli_{$command}";
                     $class = new $className();
                     if (is_a($class, "cliCommand")) {
                         $commands[] = $command;
                     }
                 }
             }
         }
         closedir($handle);
     }
     sort($commands);
     return implode(" ", $commands);
 }
 /**
  * @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;
 }
Example #4
0
 function encode($src = null, $dest = null)
 {
     if (is_string($src)) {
         if (is_null($dest)) {
             if (!($src = fopen($src, 'r'))) {
                 return false;
             }
             while (!feof($src)) {
                 echo base64_encode(fread($src, 3 * 1024));
             }
             fclose($src);
             return true;
         } else {
             if (is_a($dest, 'Utils_OutputWriter')) {
                 if (!($src = fopen($src, 'r'))) {
                     return false;
                 }
                 while (!feof($src)) {
                     $dest->write(base64_encode(fread($src, 3 * 1024)));
                 }
                 fclose($src);
                 return true;
             }
         }
     }
     return false;
 }
Example #5
0
 /** Set the order of the comments. */
 public function OrderBy($Value = NULL)
 {
     if ($Value === NULL) {
         return $this->_OrderBy;
     }
     if (is_string($Value)) {
         $Value = array($Value);
     }
     if (is_array($Value)) {
         // Set the order of this object.
         $OrderBy = array();
         foreach ($Value as $Part) {
             if (StringEndsWith($Part, ' desc', TRUE)) {
                 $OrderBy[] = array(substr($Part, 0, -5), 'desc');
             } elseif (StringEndsWith($Part, ' asc', TRUE)) {
                 $OrderBy[] = array(substr($Part, 0, -4), 'asc');
             } else {
                 $OrderBy[] = array($Part, 'asc');
             }
         }
         $this->_OrderBy = $OrderBy;
     } elseif (is_a($Value, 'Gdn_SQLDriver')) {
         // Set the order of the given sql.
         foreach ($this->_OrderBy as $Parts) {
             $Value->OrderBy($Parts[0], $Parts[1]);
         }
     }
 }
Example #6
0
 /**
  * SCENARIO OUTLINE: Export article in DC format over OAI
  *   GIVEN a DOI and a URN have been assigned for a given {publishing object}
  *    WHEN I export the corresponding article in DC format over OAI
  *    THEN DOI and URN specific {DC fields} will be present in the OAI-message.
  *
  * EXAMPLES:
  *   publishing object | DC fields
  *   ==================|================================================
  *   issue             | <dc:source>10.4321/t.v1i1</dc:source>
  *   issue             | <dc:source>urn:nbn:de:0000-t.v1i19</dc:source>
  *   article           | <dc:identifier>10.4321/t.v1i1.1</dc:identifier>
  *   article           | <dc:identifier>urn:nbn:de:0000-t.v1i1.18</dc:identifier>
  *   galley            | <dc:relation>10.4321/t.v1i1.g1</dc:relation>
  *   galley            | <dc:relation>urn:nbn:de:0000-t.v1i1.1.g17</dc:relation>
  *   supp-file         | <dc:relation>10.4321/t.v1i1.s1</dc:relation>
  *   supp-file         | <dc:relation>urn:nbn:de:0000-t.v1i1.1.s19</dc:relation>
  */
 public function testDOIAndURN()
 {
     // Configure the web service request
     $params = array('verb' => 'GetRecord', 'metadataPrefix' => 'oai_dc', 'identifier' => 'oai:' . Config::getVar('oai', 'repository_id') . ':article/1');
     $this->webServiceRequest->setParams($params);
     // Check DOI node with XPath.
     $namespaces = array('oai_dc' => 'http://www.openarchives.org/OAI/2.0/oai_dc/', 'dc' => 'http://purl.org/dc/elements/1.1/');
     $domXPath = $this->getXPath($namespaces);
     $testCases = array('/oai:OAI-PMH/oai:GetRecord/oai:record/oai:metadata/oai_dc:dc/dc:source' => array('urn:nbn:de:0000-t.v1i19', '10.1234/t.v1i1'), '/oai:OAI-PMH/oai:GetRecord/oai:record/oai:metadata/oai_dc:dc/dc:identifier' => array('urn:nbn:de:0000-t.v1i1.18', '10.1234/t.v1i1.1'), '/oai:OAI-PMH/oai:GetRecord/oai:record/oai:metadata/oai_dc:dc/dc:relation' => array('urn:nbn:de:0000-t.v1i1.1.g17', 'urn:nbn:de:0000-t.v1i1.1.s19', '10.1234/t.v1i1.1.g1', '10.1234/t.v1i1.1.s1'));
     foreach ($testCases as $xPath => $expectedDoiList) {
         $nodeList = $domXPath->query($xPath);
         self::assertGreaterThan(1, $nodeList->length, "Error while checking {$xPath}: No nodes found.");
         foreach ($expectedDoiList as $expectedDoi) {
             for ($index = 1; $index <= $nodeList->length; $index++) {
                 $node = $nodeList->item($index - 1);
                 // self::assertType() has been removed from PHPUnit 3.6
                 // but self::assertInstanceOf() is not present in PHPUnit 3.4
                 // which is our current test server version.
                 // FIXME: change this to assertInstanceOf() after upgrading the
                 // test server.
                 self::assertTrue(is_a($node, 'DOMNode'));
                 if ($node->textContent == $expectedDoi) {
                     break;
                 }
             }
             if ($index > $nodeList->length) {
                 self::fail("Error while checking {$xPath}: Node with {$expectedDoi} not found.");
             }
         }
     }
 }
Example #7
0
 function &setFrontendClass($uiclass)
 {
     if (is_object($GLOBALS['_PEAR_FRONTEND_SINGLETON']) && is_a($GLOBALS['_PEAR_FRONTEND_SINGLETON'], $uiclass)) {
         return $GLOBALS['_PEAR_FRONTEND_SINGLETON'];
     }
     if (!class_exists($uiclass)) {
         $file = str_replace('_', '/', $uiclass) . '.php';
         if (PEAR_Frontend::isIncludeable($file)) {
             include_once $file;
         }
     }
     if (class_exists($uiclass)) {
         $obj =& new $uiclass();
         // quick test to see if this class implements a few of the most
         // important frontend methods
         if (method_exists($obj, 'userConfirm')) {
             $GLOBALS['_PEAR_FRONTEND_SINGLETON'] =& $obj;
             $GLOBALS['_PEAR_FRONTEND_CLASS'] = $uiclass;
             return $obj;
         } else {
             $err = PEAR::raiseError("not a frontend class: {$uiclass}");
             return $err;
         }
     }
     $err = PEAR::raiseError("no such class: {$uiclass}");
     return $err;
 }
Example #8
0
 /**
  * Singleton implementation
  *
  * @return object
  */
 public static function instance()
 {
     if (!is_a(self::$__instance, 'Jetpack_Protect_Module')) {
         self::$__instance = new Jetpack_Protect_Module();
     }
     return self::$__instance;
 }
 private function normalizeResponse($response = null)
 {
     if ($response === null) {
         return new Response();
     }
     switch (gettype($response)) {
         case 'array':
         case 'boolean':
         case 'int':
         case 'double':
             return new Response(json_encode($response));
         case 'object':
             if (is_a($response, 'Response')) {
                 return $response;
             } else {
                 if (is_a($response, 'HTTPException')) {
                     return new Response(array('message' => $response->getMessage(), 'code' => $response->getCode()), $response->getCode());
                 } else {
                     return new Response(json_encode($response));
                 }
             }
         default:
             return new Response(json_encode($response));
     }
 }
/**
 * Create a Membership Status
 *
 * This API is used for creating a Membership Status
 *
 * @param   array  $params  an associative array of name/value property values of civicrm_membership_status
 *
 * @return array of newly created membership status property values.
 * {@getfields MembershipStatus_create}
 * @access public
 */
function civicrm_api3_membership_status_create($params)
{
    civicrm_api3_verify_one_mandatory($params, 'CRM_Member_DAO_MembershipStatus', array('name', 'label'));
    //move before verifiy? DAO check requires?
    if (empty($params['name'])) {
        $params['name'] = CRM_Utils_Array::value('label', $params);
    }
    //don't allow duplicate names.
    require_once 'CRM/Member/DAO/MembershipStatus.php';
    $status = new CRM_Member_DAO_MembershipStatus();
    $status->name = $params['name'];
    if ($status->find(TRUE)) {
        return civicrm_api3_create_error(ts('A membership status with this name already exists.'));
    }
    require_once 'CRM/Member/BAO/MembershipStatus.php';
    $ids = array();
    $membershipStatusBAO = CRM_Member_BAO_MembershipStatus::add($params, $ids);
    if (is_a($membershipStatusBAO, 'CRM_Core_Error')) {
        return civicrm_api3_create_error("Membership is not created");
    } else {
        $values = array();
        $values['id'] = $membershipStatusBAO->id;
        $values['is_error'] = 0;
        return civicrm_api3_create_success($values, $params);
    }
}
 /**
  * @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'));
         }
     }
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app['parameters'] = $this->app->share(function ($app) {
         return new Parameters();
     });
     // Find the default Controller class of the current Laravel application
     $controllerClass = $this->app['config']->get('authority-controller.controllerClass', 'Illuminate\\Routing\\Controller');
     $this->app->resolving(function ($object) use($controllerClass) {
         // Check if the current $object class is a Controller class and if it responds to paramsBeforeFilter method
         if (is_a($object, $controllerClass) && respond_to($object, 'paramsBeforeFilter')) {
             // Fill $params properties of the current controller
             $this->app['parameters']->fillController($object);
         }
     });
     $this->app['authority'] = $this->app->share(function ($app) {
         $user = $app['auth']->user();
         $authority = new Authority($user);
         $fn = $app['config']->get('authority-controller.initialize');
         $serializer = new Serializer();
         if (is_string($fn)) {
             $fn = $serializer->unserialize($fn);
         }
         if ($fn) {
             $fn($authority);
         }
         return $authority;
     });
     $this->app->bind('Efficiently\\AuthorityController\\ControllerResource', function ($app, $parameters) {
         list($controller, $resourceName, $resourceOptions) = $parameters;
         return new ControllerResource($controller, $resourceName, $resourceOptions);
     });
 }
 /**
  * Set the form
  * @param $form object
  */
 function setForm($form)
 {
     if ($form) {
         assert(is_a($form, 'Form'));
     }
     $this->_form = $form;
 }
 /**
  * Get the authorized submission.
  * @return Submission
  */
 function getSubmission()
 {
     // We assume proper authentication by the data provider.
     $submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
     assert(is_a($submission, 'Submission'));
     return $submission;
 }
Example #15
0
 /**
  * Excluí registro da tabela
  * @param int|ValueObject $VO_or_ID
  * @return boolean
  */
 public function Excluir($VO_or_ID = null)
 {
     try {
         $Value = $VO_or_ID;
         # Value Object
         if (is_a($Value, 'ValueObject')) {
             if ($Value->getTable() != $this->Table) {
                 throw new Exception('Inválido: ' . $Value->getTable() . ' != ' . $this->Table);
             } else {
                 if (!$Value->getId()) {
                     throw new Exception('Registro não se encontra na base de dados.');
                 }
             }
             $id = $Value->getId();
         } else {
             if (is_int($Value) or is_string($Value)) {
                 $id = $Value;
             } else {
                 throw new Exception('Precisa ser passado um ValueObject ou um Int para excluir um registro.');
             }
         }
         # Excluíndo
         $this->_Delete($this->Table, 'WHERE `id` = :id LIMIT 1', ['id' => $id]);
         # Excluí todas as imagens da ValueObject
         if (is_object($Value)) {
             $Value->imgDeleteAll();
         }
     } catch (Exception $ex) {
         throw new Exception($ex->getMessage());
     }
 }
Example #16
0
 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $defaultFieldOptions = ['multiple' => true];
     $resolver->setDefaults(['dictionary_code' => null, 'class' => null, 'field_options' => $defaultFieldOptions]);
     $resolver->setNormalizers(['class' => function (Options $options, $value) {
         if ($value !== null) {
             return $value;
         }
         if (empty($options['dictionary_code'])) {
             throw new InvalidOptionsException('Either "class" or "dictionary_code" must option must be set.');
         }
         $class = ExtendHelper::buildEnumValueClassName($options['dictionary_code']);
         if (!is_a($class, 'Oro\\Bundle\\EntityExtendBundle\\Entity\\AbstractEnumValue', true)) {
             throw new InvalidOptionsException(sprintf('"%s" must be a child of "%s"', $class, 'Oro\\Bundle\\EntityExtendBundle\\Entity\\AbstractEnumValue'));
         }
         return $class;
     }, 'field_options' => function (Options $options, $value) use(&$defaultFieldOptions) {
         if (isset($options['class'])) {
             $nullValue = null;
             if ($options->has('null_value')) {
                 $nullValue = $options->get('null_value');
             }
             $value['choices'] = $this->getChoices($options['class'], $nullValue);
         } else {
             $value['choices'] = [];
         }
         return array_merge($defaultFieldOptions, $value);
     }]);
 }
Example #17
0
 /**
  * Checks if given element is valid ype for this collection
  *
  * @param $element
  * @return bool
  */
 protected function isValid($element)
 {
     if (is_object($element) && is_a($element, $this->type)) {
         return true;
     }
     return false;
 }
Example #18
0
 public function testRunWithReporter()
 {
     $report = Dispatcher::run(null, array('reporter' => 'html'));
     $this->assertTrue(is_a($report, '\\lithium\\test\\Report'));
     $result = $report->group;
     $this->assertTrue(is_a($result, '\\lithium\\test\\Group'));
 }
Example #19
0
 private function _recurseInput(Pagemill_Node $node, Pagemill_Stream $stream, array $elements, array $attributes, Pagemill_Data $data)
 {
     if (is_a($node, 'Pagemill_Tag_Template')) {
         foreach ($node->children() as $c) {
             $this->_recurseInput($c, $stream, $elements, $attributes, $data);
         }
     } else {
         if (is_a($node, 'Pagemill_Tag')) {
             if (in_array('*', $elements) || in_array($node->name(), $elements)) {
                 if (is_a($node, 'Pagemill_Tag_Comment')) {
                     /*$stream->puts('<!--');
                     		foreach ($node->children() as $child) {
                     			$child->rawOutput($stream, false);
                     		}
                     		$stream->puts('-->');*/
                 } else {
                     if (is_a($node, 'Pagemill_Tag_Html_Script')) {
                         $node->process($data, $stream);
                     } else {
                         if ($node->name() == 'img') {
                             $img = new Typeframe_Tag_Timg('img', $node->attributes(), $this);
                             $img->process($data, $stream);
                         } else {
                             $stream->puts('<' . $node->name());
                             foreach ($node->attributes() as $k => $v) {
                                 if (in_array('*', $attributes) || in_array($node->name() . '.*', $attributes) || in_array($node->name() . ".{$k}", $attributes)) {
                                     if ($k == 'src' || $k == 'href') {
                                         $v = $data->parseVariables(Typeframe_Attribute_Url::ConvertShortUrlToExpression($v));
                                     }
                                     $stream->puts(' ' . $k . '="' . htmlentities($v) . '"');
                                 }
                             }
                             if (count($node->children()) == 0) {
                                 if ($node->collapse) {
                                     $stream->puts('/>');
                                 } else {
                                     $stream->puts('></' . $node->name() . '>');
                                 }
                             } else {
                                 $stream->puts('>');
                                 foreach ($node->children() as $c) {
                                     $this->_recurseInput($c, $stream, $elements, $attributes, $data);
                                 }
                                 $stream->puts('</' . $node->name() . '>');
                             }
                         }
                     }
                 }
             } else {
                 // Tag is not in element whitelist
                 // Recurse through its children and return content without unpermitted tags
                 foreach ($node->children() as $c) {
                     $this->_recurseInput($c, $stream, $elements, $attributes, $data);
                 }
             }
         } else {
             $node->rawOutput($stream);
         }
     }
 }
 /**
  * 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);
 }
Example #21
0
 public function getPluginInfo()
 {
     if (!is_a($this->pluginInfo, 'PluginInfo')) {
         $this->pluginInfo = new PluginInfo($this);
     }
     return $this->pluginInfo;
 }
Example #22
0
 public function process()
 {
     if (!parent::process()) {
         $this->redirectNoSession();
     }
     $containers = array();
     $containerClassFiles = scandir(\base_config::$baseDir . '/inc/dashcontainers/');
     foreach ($containerClassFiles as $containerClassFile) {
         if (strpos($containerClassFile, '.php') === false) {
             continue;
         }
         $containerClassFile = str_replace('.php', '', $containerClassFile);
         $containerObject = new $containerClassFile($this);
         if (is_a($containerObject, '\\interfaces\\dashcontainer')) {
             $containerPosition = $containerObject->getPosition();
             if (isset($containers[$containerPosition])) {
                 $containerPosition++;
             }
             $containers[$containerPosition] = new \model\dashboard_container($containerObject->getBoxName(), $containerObject->getBoxHeadline(), $containerObject->getBoxContent(), $containerObject->getSize(), $containerObject->getHeight());
         } else {
             $message = \language::replaceLanguageConstant(\language::returnLanguageConstant('DASH_CONTAINER_INSTANCE'), array('{{dashcontainer}}' => $containerClassFile));
             \messages::registerError($message);
         }
     }
     if (count($containers) >= 1) {
         ksort($containers);
     }
     $view = new \model\view_acp('dashboard');
     $view->assign('statsContainers', $containers);
     $view->render();
 }
Example #23
0
 /**
  * Determina que o login é necessário
  */
 public function LoginNecessario()
 {
     if (!isset($_SESSION["usuario"]) || !is_a($_SESSION["usuario"], "Usuario")) {
         header("Location: /transporte/usuario/login.php");
         die;
     }
 }
Example #24
0
 /**
  * @param \checkTypes\Handler   $handler
  * @param \checkTypes\Parameter $parameter
  * @param boolean               $strict
  *
  * @return boolean
  */
 public function isValid(Handler $handler, Parameter $parameter, $strict = false)
 {
     if ($this->nexValidator === NULL) {
         return false;
     }
     $isValid = false;
     $types = explode('|', $parameter->type);
     foreach ($types as $type) {
         if (substr($type, -2) == '[]') {
             if (!is_array($parameter->value) && !is_a($parameter->value, '\\Traversable')) {
                 continue;
             }
             $type = substr($type, 0, -2);
             foreach ($parameter->value as $value) {
                 $clone = clone $parameter;
                 $clone->type = $type;
                 $clone->value = $value;
                 $isValid = $this->isValid($handler, $clone, $strict);
                 if (!$isValid) {
                     break;
                 }
             }
         } else {
             $isValid = $this->nexValidator->isValid($handler, $parameter, $strict);
         }
         if ($isValid) {
             break;
         }
     }
     return $isValid;
 }
 /**
  *
  * @return array
  */
 public function dismount()
 {
     if (is_a($this->object, 'Lightwork\\Foundation\\Model\\Model')) {
         return $this->object->toArray();
     }
     $array = array();
     foreach ($this->reflectionClass->getProperties() as $property) {
         $property->setAccessible(true);
         $value = $property->getValue($this->object);
         if (is_object($value)) {
             if (is_a($value, 'Lightwork\\Foundation\\Model\\Model')) {
                 $value = $value->toArray();
             } else {
                 $reflection = new ReflectionUtility($value);
                 $value = $reflection->dismount();
             }
         } else {
             if (is_array($value)) {
                 foreach ($value as $k => $v) {
                     if (is_object($v)) {
                         $reflection = new ReflectionUtility($v);
                         $value[$k] = $reflection->dismount();
                     }
                 }
             }
         }
         $array[$property->getName()] = $value;
         $property->setAccessible(false);
     }
     return $array;
 }
 /**
  * takes an associative array and creates a price field object
  *
  * This function is invoked from within the web form layer and also from the api layer
  *
  * @param array $params (reference) an assoc array of name/value pairs
  *
  * @return object CRM_Price_DAO_PriceField object
  * @access public
  * @static
  */
 static function create(&$params)
 {
     if (empty($params['id']) && empty($params['name'])) {
         $params['name'] = strtolower(CRM_Utils_String::munge($params['label'], '_', 242));
     }
     $transaction = new CRM_Core_Transaction();
     $priceField = self::add($params);
     if (is_a($priceField, 'CRM_Core_Error')) {
         $transaction->rollback();
         return $priceField;
     }
     $optionsIds = array();
     $maxIndex = CRM_Price_Form_Field::NUM_OPTION;
     if ($priceField->html_type == 'Text') {
         $maxIndex = 1;
         $fieldValue = new CRM_Price_DAO_PriceFieldValue();
         $fieldValue->price_field_id = $priceField->id;
         // update previous field values( if any )
         if ($fieldValue->find(TRUE)) {
             $optionsIds['id'] = $fieldValue->id;
         }
     }
     $defaultArray = array();
     //html type would be empty in update scenario not sure what would happen ...
     if (!empty($params['html_type']) && $params['html_type'] == 'CheckBox' && isset($params['default_checkbox_option'])) {
         $tempArray = array_keys($params['default_checkbox_option']);
         foreach ($tempArray as $v) {
             if ($params['option_amount'][$v]) {
                 $defaultArray[$v] = 1;
             }
         }
     } else {
         if (!empty($params['default_option'])) {
             $defaultArray[$params['default_option']] = 1;
         }
     }
     for ($index = 1; $index <= $maxIndex; $index++) {
         if (array_key_exists('option_amount', $params) && array_key_exists($index, $params['option_amount']) && (CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_label', $params)) || !empty($params['is_quick_config'])) && !CRM_Utils_System::isNull($params['option_amount'][$index])) {
             $options = array('price_field_id' => $priceField->id, 'label' => trim($params['option_label'][$index]), 'name' => CRM_Utils_String::munge($params['option_label'][$index], '_', 64), 'amount' => CRM_Utils_Rule::cleanMoney(trim($params['option_amount'][$index])), 'count' => CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_count', $params), NULL), 'max_value' => CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_max_value', $params), NULL), 'description' => CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_description', $params), NULL), 'membership_type_id' => CRM_Utils_Array::value($index, CRM_Utils_Array::value('membership_type_id', $params), NULL), 'weight' => $params['option_weight'][$index], 'is_active' => 1, 'is_default' => CRM_Utils_Array::value($params['option_weight'][$index], $defaultArray) ? $defaultArray[$params['option_weight'][$index]] : 0, 'membership_num_terms' => NULL);
             if ($options['membership_type_id']) {
                 $options['membership_num_terms'] = CRM_Utils_Array::value($index, CRM_Utils_Array::value('membership_num_terms', $params), 1);
             }
             if (CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_financial_type_id', $params))) {
                 $options['financial_type_id'] = $params['option_financial_type_id'][$index];
             } elseif (!empty($params['financial_type_id'])) {
                 $options['financial_type_id'] = $params['financial_type_id'];
             }
             if ($opIds = CRM_Utils_Array::value('option_id', $params)) {
                 if ($opId = CRM_Utils_Array::value($index, $opIds)) {
                     $optionsIds['id'] = $opId;
                 } else {
                     $optionsIds['id'] = NULL;
                 }
             }
             CRM_Price_BAO_PriceFieldValue::create($options, $optionsIds);
         }
     }
     $transaction->commit();
     return $priceField;
 }
 /**
  * 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.
 }
Example #28
0
function hocwp_mail_test_smtp_setting($to_email)
{
    global $phpmailer;
    if (!is_object($phpmailer) || !is_a($phpmailer, 'PHPMailer')) {
        require ABSPATH . WPINC . '/class-phpmailer.php';
        require ABSPATH . WPINC . '/class-smtp.php';
        $phpmailer = new PHPMailer(true);
    }
    $subject = __('SMTP Email', 'hocwp-theme') . ': ' . sprintf(__('Test mail to %s', 'hocwp-theme'), $to_email);
    $message = __('Thank you for using HocWP, your SMTP mail settings work successfully.', 'hocwp-theme');
    $phpmailer->SMTPDebug = true;
    ob_start();
    $result = wp_mail($to_email, $subject, $message);
    $smtp_debug = ob_get_clean();
    $test_message = '<p><strong>' . __('Test Message Sent', 'hocwp-theme') . '</strong></p>';
    ob_start();
    var_dump($result);
    $result = ob_get_clean();
    $test_message .= '<p>' . sprintf(__('The result was: %s', 'hocwp-theme'), $result) . '</p>';
    $test_message .= '<p>' . __('The full debugging output is shown below:', 'hocwp-theme') . '</p>';
    ob_start();
    var_dump($phpmailer);
    $mailer_debug = ob_get_clean();
    $test_message .= '<pre>' . $mailer_debug . '</pre>';
    $test_message .= '<p>' . __('The SMTP debugging output is shown below:', 'hocwp-theme') . '</p>';
    $test_message .= '<pre>' . $smtp_debug . '</pre>';
    return $test_message;
}
Example #29
0
 /**
  * Wraps the included page in a div and writes section edits for the action component
  * so it can detect where an included page starts/ends.
  *
  * @author Michael Klier <*****@*****.**>
  * @author Michael Hamann <*****@*****.**>
  */
 function render($mode, Doku_Renderer &$renderer, $data)
 {
     if ($mode == 'xhtml') {
         list($state, $page, $redirect, $secid) = $data;
         switch ($state) {
             case 'open':
                 if ($redirect) {
                     $renderer->startSectionEdit(0, 'plugin_include_start', $page);
                 } else {
                     $renderer->startSectionEdit(0, 'plugin_include_start_noredirect', $page);
                 }
                 $renderer->finishSectionEdit();
                 // Start a new section with type != section so headers in the included page
                 // won't print section edit buttons of the parent page
                 $renderer->startSectionEdit(0, 'plugin_include_end', $page);
                 if ($secid === NULL) {
                     $id = '';
                 } else {
                     $id = ' id="' . $secid . '"';
                 }
                 $renderer->doc .= '<div class="plugin_include_content plugin_include__' . $page . '"' . $id . '>' . DOKU_LF;
                 if (is_a($renderer, 'renderer_plugin_dw2pdf')) {
                     $renderer->doc .= '<a name="' . $secid . '" />';
                 }
                 break;
             case 'close':
                 $renderer->finishSectionEdit();
                 $renderer->doc .= '</div>' . DOKU_LF;
                 break;
         }
         return true;
     }
     return false;
 }
 /**
  * {@inheritdoc}
  */
 protected function getConstructor(array &$data, $class, array &$context, \ReflectionClass $reflectionClass, $allowedAttributes)
 {
     if (is_a($class, StaticConstructorDummy::class, true)) {
         return new \ReflectionMethod($class, 'create');
     }
     return parent::getConstructor($data, $class, $context, $reflectionClass, $allowedAttributes);
 }