Example #1
0
 /**
  * Returns array of special entity data which is used, for example, in "Who has access" datagrid,
  * "oro_share_select" form type search result.
  *
  * @param object $object
  *
  * @return array
  */
 public function getEntityDetails($object)
 {
     $id = $label = $details = $image = $avatar = $classLabel = null;
     if ($object instanceof Organization) {
         $id = $object->getId();
         $label = $object->getName();
         $image = 'avatar-organization-small.png';
         $classLabel = $this->translator->trans('oro.organization.entity_label');
         $details = $classLabel;
     } elseif ($object instanceof BusinessUnit) {
         $id = $object->getId();
         $label = $object->getName();
         $image = 'avatar-business-unit-small.png';
         $classLabel = $this->translator->trans('oro.organization.businessunit.entity_label');
         $details = $classLabel . ' ' . $this->translator->trans('oro.security.datagrid.share_grid_row_details_from') . ' ' . $object->getOrganization()->getName();
     } elseif ($object instanceof User) {
         $id = $object->getId();
         $label = $object->getFirstName() . ' ' . $object->getLastName();
         $image = 'avatar-small.png';
         $classLabel = $this->translator->trans('oro.user.entity_label');
         $avatar = $object->getAvatar() ? $this->attachmentManager->getResizedImageUrl($object->getAvatar(), AttachmentManager::SMALL_IMAGE_WIDTH, AttachmentManager::SMALL_IMAGE_HEIGHT) : null;
         $details = $classLabel . ' ' . $this->translator->trans('oro.security.datagrid.share_grid_row_details_from') . ' ' . $object->getOwner()->getName();
     }
     return ['id' => $id, 'label' => $label, 'image' => $image, 'avatar' => $avatar, 'details' => $details, 'classLabel' => $classLabel];
 }
 /**
  * 
  * @param \Opit\OpitHrm\StatusBundle\Entity\Status $status
  * @param array $nextStates
  * @param object $resource
  * @param integer $requiredStatus
  */
 protected function prepareEmail(Status $status, array $nextStates, $resource, $requiredStatus)
 {
     $this->removeTokens($resource->getId());
     $applicantToken = $this->setApplicantToken($resource->getId());
     $applicationName = $this->options['applicationName'];
     $templateVars = array();
     $templateVars['currentState'] = $status->getName();
     $templateVars['nextStates'] = $nextStates;
     $templateVars['applicant'] = $resource;
     $templateVars['stateChangeLinks'] = array();
     foreach ($nextStates as $key => $value) {
         if ($key !== $requiredStatus) {
             // Generate links that can be used to change the status of the travel request
             $templateVars['stateChangeLinks'][] = $this->router->generate('OpitOpitHrmHiringBundle_change_status', array('hmId' => $resource->getJobPosition()->getHiringManager()->getId(), 'status' => $key, 'token' => $applicantToken), true);
         }
     }
     $recipient = $resource->getJobPosition()->getHiringManager()->getEmail();
     $statusName = $status->getName();
     $this->mailer->setRecipient($recipient);
     if (Status::CREATED === $status->getId()) {
         $this->mailer->setSubject('[' . ($applicationName !== null && $applicationName != 'OPIT-HRM' ? $applicationName : 'OPIT-HRM') . '] - New applicant created (' . $resource->getName() . ')');
     } else {
         $this->mailer->setSubject('[' . ($applicationName !== null && $applicationName != 'OPIT-HRM' ? $applicationName : 'OPIT-HRM') . '] - Applicant status changed - ' . $statusName . ' (' . $resource->getName() . ')');
     }
     $this->mailer->setBodyByTemplate('OpitOpitHrmHiringBundle:Mail:applicant.html.twig', $templateVars);
     $this->mailer->sendMail();
 }
 /**
  * Set a property on a given object to a given value.
  *
  * Checks if the setter or the property are public are made before
  * calling this method.
  *
  * @param object $object   Object to set property on
  * @param object $accessor ReflectionMethod or ReflectionProperty
  * @param mixed  $value    Value of property
  *
  * @return void
  */
 protected function setProperty($object, $accessor, $value)
 {
     if ($accessor instanceof \ReflectionProperty) {
         $object->{$accessor->getName()} = $value;
     } else {
         if ($accessor instanceof ReflectionContainer) {
             $object->{$accessor->getName()}($accessor->getField(), $value);
         } else {
             $object->{$accessor->getName()}($value);
         }
     }
 }
Example #4
0
 /**
  * Displays the random albums block
  * @author Ross Carlson
  * @version 12/22/04
  * @since 12/22/04
  * @param object $node the node that we are looking at
  * @param string $level The level we are looking at, like a subartist
  */
 function classicRandomAlbums(&$node, $level = "")
 {
     global $hierarchy;
     $title = word("Random Albums");
     if ($node->getName() != "") {
         $title = word("Random Albums") . " :: " . $node->getName();
     }
     $this->blockHeader($title);
     $this->blockBodyOpen();
     $this->randomAlbums($node, $level);
     $this->blockBodyClose();
 }
    /**
     * Constructor
     * 
     * @param	object	$form	the form calling the editor selection	
     * @param	string	$name	editor name
     * @param	string	$value	Pre-selected text value
     * @param	bool	$noHtml  dohtml disabled
     */
    function XoopsFormSelectEditor(&$form, $name = "editor", $value = null, $noHtml = false)
    {
        $this->XoopsFormElementTray(_SELECTEDITOR);
        $editor_handler =& xoops_gethandler("editor");
        $option_select = new XoopsFormSelect("", $name, $value);
        $extra = 'onchange="if(this.options[this.selectedIndex].value.length > 0 ){
			window.document.forms.' . $form->getName() . '.skipValidationJS.value=1;
			window.document.forms.' . $form->getName() . '.submit();
			}"';
        $option_select->setExtra($extra);
        $option_select->addOptionArray($editor_handler->getList($noHtml));
        $this->addElement($option_select);
    }
 /**
  *	sendAttachNotice - contains the logic to send out email attachement followups when a message is posted.
  *
  *	@param int	attach_id	- The id of the file that has been attached
  *
  *	@return boolean success.
  */
 function sendAttachNotice($attach_id)
 {
     if ($attach_id) {
         $ids =& $this->Forum->getMonitoringIDs();
         //
         //	See if there is anyone to send messages to
         //
         if (!count($ids) > 0 && !$this->Forum->getSendAllPostsTo()) {
             return true;
         }
         $body = "\nRead and respond to this message at: " . "\n" . util_make_url('/forum/message.php?msg_id=' . $this->getID()) . "\nBy: " . $this->getPosterRealName() . "\n\n";
         $body .= "A file has been uploaded to this message, you can download it at: " . "\n" . util_make_url('/forum/attachment.php?attachid=' . $attach_id . "&group_id=" . $this->Forum->Group->getID() . "&forum_id=" . $this->Forum->getID()) . "\n\n";
         $body .= "\n\n______________________________________________________________________" . "\nYou are receiving this email because you elected to monitor this forum." . "\nTo stop monitoring this forum, login to " . $GLOBALS['sys_name'] . " and visit: " . "\n" . util_make_url('/forum/monitor.php?forum_id=' . $this->Forum->getID() . '&group_id=' . $this->Forum->Group->getID() . '&stop=1');
         $extra_headers = "Return-Path: <noreply@" . $GLOBALS['sys_default_domain'] . ">\n";
         $extra_headers .= "Errors-To: <noreply@" . $GLOBALS['sys_default_domain'] . ">\n";
         $extra_headers .= "Sender: <noreply@" . $GLOBALS['sys_default_domain'] . ">\n";
         $extra_headers .= "Reply-To: " . $this->Forum->getReturnEmailAddress() . "\n";
         $extra_headers .= "Precedence: Bulk\n" . "List-Id: " . $this->Forum->getName() . " <forum" . $this->Forum->getId() . "@" . $GLOBALS['sys_default_domain'] . ">\n" . "List-Help: " . util_make_url('/forum/forum.php?id=' . $this->Forum->getId()) . "\n" . "Message-Id: <forumpost" . $this->getId() . "@" . $GLOBALS['sys_default_domain'] . ">";
         $parentid = $this->getParentId();
         if (!empty($parentid)) {
             $extra_headers .= "\nIn-Reply-To: " . $this->Forum->getReturnEmailAddress() . "\n" . "References: <forumpost" . $this->getParentId() . "@" . $GLOBALS['sys_default_domain'] . ">";
         }
         $subject = "[" . $this->Forum->getUnixName() . "][" . $this->getID() . "] " . util_unconvert_htmlspecialchars($this->getSubject());
         if (count($ids) != 0) {
             $sql = "SELECT email FROM users WHERE status='A' AND user_id IN ('" . implode($ids, '\',\'') . "')";
             $bccres = db_query($sql);
         }
         ($BCC =& implode(util_result_column_to_array($bccres), ',')) . ',' . $this->Forum->getSendAllPostsTo();
         $User = user_get_object($this->getPosterID());
         util_send_message('', $subject, $body, "noreply@" . $GLOBALS['sys_default_domain'], $BCC, 'Forum', $extra_headers);
         return true;
     }
     return false;
 }
Example #7
0
 /**
  * Register a new callback.
  *
  * The option array can contain the following parameters:
  * <ul>
  * <li><b>prepend:</b> Add this callback at the beginning of the existing callbacks (true) or at the end (false, default)</li>
  * </ul>
  *
  * @param string $name Name of callback type (see {@link valid_callbacks $valid_callbacks})
  * @param mixed $closure_or_method_name Either a closure or the name of a method on the {@link Model}
  * @param array $options Options array
  * @return void
  * @throws Activerecord if invalid callback type or callback method was not found
  */
 public function register($name, $closure_or_method_name = null, $options = [])
 {
     $options = \array_merge(['prepend' => false], $options);
     if (!$closure_or_method_name) {
         $closure_or_method_name = $name;
     }
     if (!\in_array($name, self::$valid_callbacks)) {
         throw new ExceptionActiverecord("Invalid callback: {$name}");
     }
     if (!$closure_or_method_name instanceof \Closure) {
         if (!isset($this->public_methods)) {
             $this->public_methods = \get_class_methods($this->reflect->getName());
         }
         if (!in_array($closure_or_method_name, $this->public_methods)) {
             if ($this->reflect->hasMethod($closure_or_method_name)) {
                 // Method is private or protected
                 throw new ExceptionActiverecord("Callback methods need to be public (or anonymous closures). " . "Please change the visibility of " . $this->reflect->getName() . "->" . $closure_or_method_name . "()");
             } else {
                 throw new ExceptionActiverecord("Unknown method for callback: {$name}" . (\is_string($closure_or_method_name) ? ": #{$closure_or_method_name}" : ""));
             }
         }
     }
     if (!isset($this->registry[$name])) {
         $this->registry[$name] = [];
     }
     if ($options['prepend']) {
         \array_unshift($this->registry[$name], $closure_or_method_name);
     } else {
         $this->registry[$name][] = $closure_or_method_name;
     }
 }
Example #8
0
 /**
  * Constructor.
  *
  * @param   string  $date  String in a format accepted by strtotime(), defaults to "now".
  * @param   mixed   $tz    Time zone to be used for the date.
  * @return  void
  * @throws  Exception
  */
 public function __construct($date = 'now', $tz = null)
 {
     // Create the base GMT and server time zone objects.
     if (empty(self::$gmt) || empty(self::$stz)) {
         self::$gmt = new DateTimeZone('GMT');
         self::$stz = new DateTimeZone(@date_default_timezone_get());
     }
     // If the time zone object is not set, attempt to build it.
     if (!$tz instanceof DateTimeZone) {
         if ($tz === null) {
             $tz = self::$gmt;
         } elseif (is_numeric($tz)) {
             // Translate from offset.
             $tz = new DateTimeZone(self::$offsets[(string) $tz]);
         } elseif (is_string($tz)) {
             $tz = new DateTimeZone($tz);
         }
     }
     // If the date is numeric assume a unix timestamp and convert it.
     date_default_timezone_set('UTC');
     $date = is_numeric($date) ? date('c', $date) : $date;
     // Call the DateTime constructor.
     parent::__construct($date, $tz);
     // reset the timezone for 3rd party libraries/extension that does not use JDate
     date_default_timezone_set(self::$stz->getName());
     // Set the timezone object for access later.
     $this->_tz = $tz;
 }
Example #9
0
 /**
  * Constructor.
  *
  * @param   string  $date  String in a format accepted by strtotime(), defaults to "now".
  * @param   mixed   $tz    Time zone to be used for the date. Might be a string or a DateTimeZone object.
  *
  * @since   11.1
  */
 public function __construct($date = 'now', $tz = null)
 {
     // Create the base GMT and server time zone objects.
     if (empty(self::$gmt) || empty(self::$stz)) {
         self::$gmt = new DateTimeZone('GMT');
         self::$stz = new DateTimeZone(@date_default_timezone_get());
     }
     // If the time zone object is not set, attempt to build it.
     if (!$tz instanceof DateTimeZone) {
         if ($tz === null) {
             $tz = self::$gmt;
         } elseif (is_string($tz)) {
             $tz = new DateTimeZone($tz);
         }
     }
     // If the date is numeric assume a unix timestamp and convert it.
     date_default_timezone_set('UTC');
     $date = is_numeric($date) ? date('c', $date) : $date;
     // If now, add the microseconds to date.
     $date = $date === 'now' ? parent::createFromFormat('U.u', number_format(microtime(true), 6, '.', ''), $tz)->format('Y-m-d H:i:s.u') : $date;
     // Call the DateTime constructor.
     parent::__construct($date, $tz);
     // Reset the timezone for 3rd party libraries/extension that does not use JDate
     date_default_timezone_set(self::$stz->getName());
     // Set the timezone object for access later.
     $this->tz = $tz;
 }
Example #10
0
 /**
  * Register a new callback.
  *
  * The option array can contain the following parameters:
  * <ul>
  * <li><b>prepend:</b> Add this callback at the beginning of the existing callbacks (true) or at the end (false, default)</li>
  * </ul>
  *
  * @param string $name Name of callback type (see {@link VALID_CALLBACKS $VALID_CALLBACKS})
  * @param mixed $closure_or_method_name Either a closure or the name of a method on the {@link Model}
  * @param array $options Options array
  * @return void
  * @throws ActiveRecordException if invalid callback type or callback method was not found
  */
 public function register($name, $closure_or_method_name = null, $options = array())
 {
     $options = array_merge(array('prepend' => false), $options);
     if (!$closure_or_method_name) {
         $closure_or_method_name = $name;
     }
     if (!in_array($name, self::$VALID_CALLBACKS)) {
         throw new ActiveRecordException("Invalid callback: {$name}");
     }
     if (!$closure_or_method_name instanceof Closure) {
         if (!isset($this->publicMethods)) {
             $this->publicMethods = get_class_methods($this->klass->getName());
         }
         if (!in_array($closure_or_method_name, $this->publicMethods)) {
             if ($this->klass->hasMethod($closure_or_method_name)) {
                 // Method is private or protected
                 throw new ActiveRecordException("Callback methods need to be public (or anonymous closures). " . "Please change the visibility of " . $this->klass->getName() . "->" . $closure_or_method_name . "()");
             } else {
                 // i'm a dirty ruby programmer
                 throw new ActiveRecordException("Unknown method for callback: {$name}" . (is_string($closure_or_method_name) ? ": #{$closure_or_method_name}" : ""));
             }
         }
     }
     if (!isset($this->registry[$name])) {
         $this->registry[$name] = array();
     }
     if ($options['prepend']) {
         array_unshift($this->registry[$name], $closure_or_method_name);
     } else {
         $this->registry[$name][] = $closure_or_method_name;
     }
 }
Example #11
0
 /**
  * @param int|null|string $name
  * @param object $data
  */
 public function __construct($name, $data, $options)
 {
     parent::__construct($name);
     $pspList = $options->get('pspList');
     $pspArray = ['' => '-- Choose PSP --'];
     if ($pspList && $pspList->count()) {
         foreach ($pspList as $psp) {
             $pspArray[$psp->getId()] = $psp->getShortName();
         }
     }
     $this->setName($name);
     $name_attr = array('type' => 'text', 'class' => 'form-control', 'id' => 'name', 'maxlength' => 150, 'value' => $data->getName());
     $conciergeEmailAttr = ['type' => 'text', 'class' => 'form-control', 'id' => 'concierge_email', 'maxlength' => 255];
     $this->add(['name' => 'concierge_email', 'attributes' => $conciergeEmailAttr]);
     $this->add(array('name' => 'name', 'attributes' => $name_attr));
     $buttons_save = 'Save Changes';
     $this->add(array('name' => 'save_button', 'options' => array('label' => $buttons_save), 'attributes' => array('type' => 'button', 'class' => 'btn btn-primary state col-sm-2 col-xs-12 margin-left-10 pull-right', 'data-loading-text' => 'Saving...', 'id' => 'save_button', 'value' => 'Save')));
     $this->add(['name' => 'psp_id', 'type' => 'Zend\\Form\\Element\\Select', 'options' => ['label' => 'PSP', 'value_options' => $pspArray], 'attributes' => ['class' => 'form-control', 'id' => 'psp-id']]);
     if (is_object($data)) {
         $objectData = new \ArrayObject();
         $objectData['concierge_email'] = $data->getEmail();
         $objectData['psp_id'] = $data->getPspId();
         $this->bind($objectData);
     }
 }
Example #12
0
	/**
	 * Get the view object attached to the controller
	 * 
	 * This function will check if the view folder exists. If not it will throw
	 * an exception. This is a security measure to make sure we can only explicitly
	 * get data from views the have been physically defined. 
	 *
	 * @throws  KControllerException if the view cannot be found.
	 * @return	KViewAbstract
	 *  
	 */
	public function getView()
	{
	    if(!$this->_view instanceof KViewAbstract)
		{	   
		    //Make sure we have a view identifier
		    if(!($this->_view instanceof KIdentifier)) {
		        $this->setView($this->_view);
			}
			
			//Create the view
			$config = array(
			    'model'  => $this->getModel(),
        	);
        	
			$this->_view = KFactory::get($this->_view, $config);
			
			//Set the layout
			if(isset($this->_request->layout)) {
        	    $this->_view->setLayout($this->_request->layout);
        	} 
			
			//Make sure the view exists
		    if(!file_exists(dirname($this->_view->getIdentifier()->filepath))) {
		        throw new KControllerException('View :'.$this->_view->getName().' not found', KHttpResponse::NOT_FOUND);
		    }
		}
		
		return $this->_view;
	}
Example #13
0
 /**
  * Check the current status of the repository
  *
  * @museDescription  Checks the current status of the repository for upgrade eligibility
  *
  * @return  void
  **/
 public function status()
 {
     $mode = $this->output->getMode();
     $status = $this->mechanism->status();
     $message = !empty($status) ? 'This repository is managed by ' . $this->mechanism->getName() . ' and has the following divergence:' : 'This repository is managed by ' . $this->mechanism->getName() . ' and is clean';
     if ($mode != 'minimal') {
         $this->output->addLine($message, array('color' => 'blue'));
     }
     $colorMap = array('added' => 'green', 'modified' => 'yellow', 'deleted' => 'cyan', 'renamed' => 'yellow', 'copied' => 'yellow', 'untracked' => 'black', 'unmerged' => 'red', 'merged' => 'blue');
     if (is_array($status) && count($status) > 0) {
         foreach ($status as $k => $v) {
             if (count($v) > 0) {
                 if ($mode == 'minimal') {
                     $this->output->addLine(array($k => $v));
                 } else {
                     $this->output->addSpacer();
                     $this->output->addLine(ucfirst($k) . ' files:');
                     foreach ($v as $file) {
                         $this->output->addLine($file, array('color' => $colorMap[$k], 'indentation' => 2));
                     }
                 }
             }
         }
     }
 }
Example #14
0
 /**
  * Gets the date in a specific format
  *
  * Returns a string formatted according to the given format. Month and weekday names and
  * other language dependent strings respect the current locale
  *
  * @param   string   $format  The date format specification string (see {@link PHP_MANUAL#strftime})
  * @param   boolean  $local   True to return the date string in the local time zone, false to return it in GMT.
  *
  * @return  string   The date as a formatted string.
  * @since   11.1
  * @deprecated Use JDate::format() instead.
  */
 public function toFormat($format = '%Y-%m-%d %H:%M:%S', $local = false)
 {
     // Set time zone to GMT as strftime formats according locale setting.
     date_default_timezone_set('GMT');
     // Generate the timestamp.
     $time = (int) parent::format('U');
     // If the returned time should be local add the GMT offset.
     if ($local) {
         $time += $this->getOffsetFromGMT();
     }
     // Manually modify the month and day strings in the format.
     if (strpos($format, '%a') !== false) {
         $format = str_replace('%a', $this->dayToString(date('w', $time), true), $format);
     }
     if (strpos($format, '%A') !== false) {
         $format = str_replace('%A', $this->dayToString(date('w', $time)), $format);
     }
     if (strpos($format, '%b') !== false) {
         $format = str_replace('%b', $this->monthToString(date('n', $time), true), $format);
     }
     if (strpos($format, '%B') !== false) {
         $format = str_replace('%B', $this->monthToString(date('n', $time)), $format);
     }
     // Generate the formatted string.
     $date = strftime($format, $time);
     // reset the timezone for 3rd party libraries/extension that does not use JDate
     date_default_timezone_set(self::$stz->getName());
     return $date;
 }
 /**
  *	sendNotice - contains the logic for sending email/jabber updates.
  *
  *	@return	boolean	success.
  */
 function sendNotice($first = false)
 {
     global $send_task_email;
     if ($send_task_email === false) {
         return true;
     }
     $ids =& $this->getAssignedTo();
     //
     //	See if there is anyone to send messages to
     //
     if (count($ids) < 1 && !$this->ProjectGroup->getSendAllPostsTo()) {
         return true;
     }
     $body = "Task #" . $this->getID() . " has been updated. " . "\n\nProject: " . $this->ProjectGroup->Group->getPublicName() . "\nSubproject: " . $this->ProjectGroup->getName() . "\nSummary: " . util_unconvert_htmlspecialchars($this->getSummary()) . "\nComplete: " . $this->getPercentComplete() . "%" . "\nStatus: " . $this->getStatusName() . "\n\nDescription: " . util_unconvert_htmlspecialchars($this->getDetails());
     /*
     	Now get the followups to this task
     */
     $result2 = $this->getMessages();
     $rows = db_numrows($result2);
     if ($result2 && $rows > 0) {
         $body .= "\n\nFollow-Ups:";
         for ($i = 0; $i < $rows; $i++) {
             $body .= "\n\n-------------------------------------------------------";
             $body .= "\nDate: " . date(_('Y-m-d H:i'), db_result($result2, $i, 'postdate'));
             $body .= "\nBy: " . db_result($result2, $i, 'user_name');
             $body .= "\n\nComment:\n" . util_unconvert_htmlspecialchars(db_result($result2, $i, 'body'));
         }
     }
     $body .= "\n\n-------------------------------------------------------" . "\nFor more info, visit:" . "\n\n" . util_make_url('/pm/task.php?func=detailtask&project_task_id=' . $this->getID() . "&group_id=" . $this->ProjectGroup->Group->getID() . "&group_project_id=" . $this->ProjectGroup->getID());
     $subject = sprintf(_('[%1$s - %2$s] [Task #%3$d] '), $this->ProjectGroup->Group->getUnixName(), $this->ProjectGroup->getName(), $this->getID()) . util_unconvert_htmlspecialchars($this->getSummary());
     util_handle_message(array_unique($ids), $subject, $body, $this->ProjectGroup->getSendAllPostsTo());
     return true;
 }
Example #16
0
 /**
  * Set identity in session
  *
  * @param object $user
  */
 private function setIdentity($user)
 {
     $st_identity = array('id' => $user->getId(), 'email' => $user->getEmail(), 'name' => $user->getName());
     if ($user->profile) {
         $st_identity['profile_picture'] = $user->profile->getPicture();
     }
     $this->session->set('auth-identity', $st_identity);
 }
Example #17
0
 /**
  * Add object title to meta
  *
  * @param object $object
  */
 public function showObjectTitle($object)
 {
     if ($object->label) {
         if (FALSE === $object->title) {
             return;
         }
         title($object->label);
     } elseif ($object->getName()) {
         title($object->getName(FALSE));
     } elseif ($object->name) {
         title($object->name);
     } else {
         if ($object->object && $object->object()->name) {
             title($object->object()->name);
         }
     }
 }
Example #18
0
 /**
  * Increase hit counter by 1
  *
  * @return this
  */
 public function hit()
 {
     if (!in_array('hits', $this->_table->getColumns())) {
         throw new KDatabaseRowException("The table " . $this->_table->getName() . " doesn't have a 'hits' column.");
     }
     $this->hits++;
     $this->save();
     return $this;
 }
Example #19
0
 /**
  * Метод для подготовки формы редактирования
  * @param object $form объект Jform
  * @param array $data данные
  */
 public function onContentPrepareForm($form, $data)
 {
     if ($form->getName() !== 'com_smfaq.smfaq') {
         return;
     }
     JForm::addFormPath(dirname(__FILE__) . DS . 'fields');
     $form->loadFile('fields', false);
     return;
 }
Example #20
0
 /**
  * Attach a handler to the session validator chain
  * 
  * @param  string $topic 
  * @param  string|object|Closure $context 
  * @param  null|string $handler 
  * @return Zend\Stdlib\SignalHandler
  */
 public function connect($topic, $context, $handler = null)
 {
     if ($context instanceof Validator) {
         $data = $context->getData();
         $name = $context->getName();
         $this->getStorage()->setMetadata('_VALID', array($name => $data));
     }
     $handle = parent::connect($topic, $context, $handler);
     return $handle;
 }
 /**
  * <p>Busca en el contenido de los comentarios de la propiedad de la clase analizada indicadores y condiciones para la validación
  * de los valores pasados por parámetro en Validacion($clase,$valores).
  * <p>Es importante por tanto que el nombre de la propiedad de la clase sea igual al índice asociativo del array $valores
  * pasados por parámetro en Validacion($clase,$valores).
  * <p>En este método se escribirán las condiciones que deben estar escritas en los comentarios PHPdocs de cada uno de las propiedades
  * a evaluar. Si se cumple la condición, se llamará a la función de validación correspondiente automáticamente.
  * 
  * @param object $propiedad -> Objetos de tipo 'Property', que contienen la información de cada una de las propiedades de la clase analizada
  */
 private function ValidaPropiedad($propiedad)
 {
     $documentacion = $propiedad->getDocComment();
     $nombre_propiedad = $propiedad->getName();
     $valor_propiedad = $this->_valores[$propiedad->getName()];
     //var_dump($documentacion);
     if (strpos($documentacion, "@requerido")) {
         $this->validaRequerido($nombre_propiedad, $valor_propiedad);
     }
     if ($pos = substr_count($documentacion, "@rango")) {
         $patron = '/@rango=(\\d{1,9}),(\\d{1,9})¬/';
         preg_match($patron, $documentacion, $doc_rango);
         // Busco en el comentario la coincidencia del patrón y almaceno el array de parámetros.
         $min = $doc_rango[1];
         $max = $doc_rango[2];
         $this->validaRango($nombre_propiedad, $valor_propiedad, $min, $max);
     }
     if (strpos($documentacion, "@validaDni")) {
         $this->validaDni($nombre_propiedad, $valor_propiedad);
     }
 }
Example #22
0
 /**
  * Method to reset the activity data.
  * Note that it will keep the current plugin id though.
  *
  * @return    void
  */
 protected function resetData()
 {
     $this->activity_data = array('id' => null);
     $this->item_data = array('asset_id' => null, 'plugin' => $this->_type . '.' . $this->_name, 'metadata' => new JRegistry());
     if ($this->activity_model) {
         $this->activity_model->setState($this->activity_model->getName() . '.id', null);
     }
     if ($this->item_model) {
         $this->item_model->setState($this->item_model->getName() . '.id', null);
         $this->item_model->setState($this->item_model->getName() . '.type', null);
     }
 }
Example #23
0
 /**
  * Displays the output of this node list.
  *
  * @return void
  *
  * @author     Benoit Grégoire <*****@*****.**>
  * @author     Francois Proulx <*****@*****.**>
  * @author     Max Horváth <*****@*****.**>
  * @copyright  2004-2006 Benoit Grégoire, Technologies Coeus inc.
  * @copyright  2004-2006 Francois Proulx, Technologies Coeus inc.
  * @copyright  2006 Max Horváth, Horvath Web Consulting
  */
 public function getOutput()
 {
     // Init ALL smarty values
     $this->_smarty->assign('DEPRECATEDisSuperAdmin', false);
     $this->_smarty->assign('GMapsEnabled', false);
     $this->_smarty->assign('nodes', array());
     $this->_smarty->assign('num_deployed_nodes', 0);
     $this->_smarty->assign('PdfSupported', false);
     $userData['preSelectedObject'] = $this->_network;
     $userData['allowEmpty'] = true;
     $userData['nullCaptionString'] = _("All");
     $userData['onChange'] = "submit.click();";
     $this->_smarty->assign('selectNetworkUI', Network::getSelectUI('network_id', $userData) . (count(Network::getAllNetworks()) > 1 ? '<input class="submit" type="submit" name="submit" value="' . _("Change network") . '">' : ""));
     $this->_smarty->assign('selectedNetworkName', $this->_network === null ? _("All networks") : $this->_network->getName());
     /**
      * Define user security levels for the template
      *
      * These values are used in the default template of WiFoDog but could be used
      * in a customized template to restrict certain links to specific user
      * access levels.
      */
     $this->_smarty->assign('DEPRECATEDisSuperAdmin', $this->_currentUser && $this->_currentUser->DEPRECATEDisSuperAdmin());
     if (defined('GMAPS_HOTSPOTS_MAP_ENABLED') && GMAPS_HOTSPOTS_MAP_ENABLED == true) {
         $this->_smarty->assign('GMapsEnabled', true);
     }
     $_html = null;
     /*
      * Main content
      */
     // Reset ALL smarty SWITCH values
     $this->_smarty->assign('sectionMAINCONTENT', false);
     // Set section of Smarty template
     $this->_smarty->assign('sectionMAINCONTENT', true);
     // Node details
     if ($this->_nodes) {
         foreach ($this->_nodes as $_nodeData) {
             $_node = Node::getObject($_nodeData['node_id']);
             $_nodeData['num_online_users'] = $_node->getNumOnlineUsers();
             $this->_smarty->append("nodes", $_nodeData);
         }
     }
     $this->_smarty->assign("num_deployed_nodes", count($this->_nodes));
     // Compile HTML code
     $_html_body = $this->_smarty->fetch("templates/sites/hotspot_status.tpl");
     /*
      * Compile HTML output
      */
     $this->_mainUI->setTitle(_("Hotspot list"));
     $this->_mainUI->appendHtmlHeadContent('<link rel="alternate" type="application/rss+xml" title="' . ($this->_network === null ? _("All networks") : $this->_network->getName()) . ": " . _("Newest Hotspots") . '" href="' . BASE_SSL_PATH . 'hotspot_status.php?format=RSS">');
     $this->_mainUI->addContent('left_area_middle', $_html);
     $this->_mainUI->addContent('main_area_middle', $_html_body);
     $this->_mainUI->display();
 }
 /**
  * Prepare the form to add to the article edit
  *
  * @param object $form
  * @param object $data
  *
  * @return bool
  */
 public function onContentPrepareForm($form, $data)
 {
     // If the category id is set, then check if the plugin should be limited to a specific category
     if (!empty($data->catid)) {
         $this->getChildCategories($data->catid);
         if ($this->limit_to_category && !$this->checkCategory($data->catid)) {
             return true;
         }
     }
     if (!$form instanceof JForm) {
         $this->_subject->setError('JERROR_NOT_A_FORM');
         return false;
     }
     // Check that we are manipulating a valid form
     $name = $form->getName();
     if (!in_array($name, array('com_content.article'))) {
         return true;
     }
     // Add the extra fields to the form
     JForm::addFormPath(dirname(__FILE__) . '/extras');
     $form->loadFile('testimonial', false);
     // Load the data from table into the form
     $articleId = isset($data->id) ? $data->id : 0;
     // If there is already an $articleId, then the article is in edit mode
     // and we need to retrieve the data from the database
     if ($articleId) {
         // Load the data from the database
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('article_id, data');
         $query->from('#__content_ksextras');
         $query->where('article_id = ' . $db->Quote($articleId));
         $db->setQuery($query);
         $attribs = $db->loadObject();
         // Check for a database error.
         if ($db->getErrorNum()) {
             $this->_subject->setError($db->getErrorMsg());
             return false;
         }
         // json_decode the data
         if (!empty($attribs->data)) {
             $ksdata = json_decode(json_decode($attribs->data));
         }
     }
     // fill in the form with data
     if (isset($attribs)) {
         foreach ($this->ksfields as $ksfield) {
             $data->attribs[$ksfield] = isset($ksdata->{$ksfield}) ? $ksdata->{$ksfield} : '';
         }
     }
     return true;
 }
 /**
  * @param array  $result
  * @param object $organization
  * @param bool   $addValue
  */
 protected function addOrganizationName(array &$result, $organization, $addValue)
 {
     if ($organization instanceof Organization) {
         if ($addValue) {
             $val = $organization->getName();
         } else {
             $val = ['type' => 'string', 'label' => $this->translator->trans('oro.email.emailtemplate.organization_name')];
         }
         $result['organizationName'] = $val;
     } elseif ($addValue) {
         $result['organizationName'] = '';
     }
 }
 /**
  * Create one element
  *
  * @param object $node
  * @access private
  * @return null
  */
 private function _generateElement($node)
 {
     $cssClasses = [];
     $classLink = [];
     $dropDownShow = '';
     if ($node->isActive()) {
         // set active parent wrapper
         $cssClasses[] = $this->_activeClass;
         // set active link
         $classLink[] = $this->_activeClass;
         // set active dropdown list
         $dropDownShow = $this->_dropChildShowClass;
     }
     if ($node->getClassLink()) {
         $classLink[] = $node->getClassLink();
     }
     if ($node->getClass()) {
         $cssClasses[] = $node->getClass();
     }
     $class = count($cssClasses) > 0 ? " class='" . implode(' ', $cssClasses) . "'" : '';
     $classLink = $node->getClassLink() ? " class='" . implode(' ', $classLink) . "'" : '';
     $id = !is_null($node->getId()) ? " id='" . $node->getId() . "'" : '';
     $target = !is_null($node->getTarget()) ? " target='" . $node->getTarget() . "'" : '';
     $click = !is_null($node->getClick()) ? " onclick='" . $node->getClick() . "'" : '';
     // generate link and wrapper <li>
     $this->_string .= "\t\t<li{$class} {$id}>" . PHP_EOL;
     $this->_string .= "\t\t\t<a " . $classLink . " title='" . $node->getName() . "' " . $click . " href='" . $node->getUrl() . "' {$target}>";
     $this->_string .= $node->getIcon() ? '<i class="' . $node->getIcon() . '"></i>' : '';
     $this->_string .= '<span class="hidden-xs"> ' . $node->getName() . '</span>';
     $this->_string .= "</a>" . PHP_EOL;
     //generate childs
     if ($node->hasChilds()) {
         $ulClass = !empty($this->_dropChildClass) ? 'class="' . $this->_dropChildClass . ' ' . $dropDownShow . '"' : '';
         $this->_string .= "\t\t<ul {$ulClass}>" . PHP_EOL;
         $this->_generateChilds($node->getChilds());
         $this->_string .= "\t\t</ul>" . PHP_EOL;
     }
     $this->_string .= "\t\t</li>" . PHP_EOL;
 }
Example #27
0
 /**
  * Ajouter un produit au panier.
  *  
  * @param object $Object
  */
 public function addToCart(&$Object, $credit, $purchase_id)
 {
     $this->Purchase_id[] = $purchase_id;
     if (array_key_exists($Object->getId(), $this->Cart)) {
         $this->Cart[$Object->getId()]['quantity']++;
         $this->Cart[$Object->getId()]['credit'] += $credit;
     } else {
         $this->Cart[$Object->getId()]['quantity'] = 1;
         $this->Cart[$Object->getId()]['name'] = $Object->getName();
         $this->Cart[$Object->getId()]['credit'] = $credit;
     }
     return 1;
 }
 /**
  * @param object $object
  * @param string|null $format
  * @param array $context
  * @return array
  */
 public function normalize($object, $format = null, array $context = array())
 {
     /* @var Item $object */
     $data = [self::ID => (string) $object->getId(), self::NAME => (string) $object->getName(), self::ICON => (string) $object->getIcon()];
     if (!is_null($object->getDescription())) {
         $data[self::DESCRIPTION] = $object->getDescription()->toNative();
     }
     $value = $object->getValue()->toNative();
     if (!empty($value)) {
         $data[self::VALUE] = $value;
     }
     $stackCount = $object->getStackCount()->toNative();
     if (!empty($stackCount)) {
         $data[self::STACK_COUNT] = $stackCount;
     }
     $bindingType = $object->getBindingType()->toNative();
     if ($bindingType == BindingType::NONE) {
         $bindingType = null;
     }
     $data[self::BINDING_TYPE] = $bindingType;
     $minimumLevel = $object->getMinimumLevel()->toNative();
     if (!empty($minimumLevel)) {
         $data[self::MINIMUM_LEVEL] = $minimumLevel;
     }
     if (!is_null($object->getDurability())) {
         $data[self::DURABILITY] = $object->getDurability()->toNative();
     }
     if (!is_null($object->getStats())) {
         if (!$this->serializer instanceof NormalizerInterface) {
             throw new \LogicException('Cannot normalize attribute "Stats" because injected serializer is not a normalizer.');
         }
         $stats = $this->serializer->normalize($object->getStats(), $format, $context);
         if (!empty($stats)) {
             $data[self::STATS] = $stats;
         }
     }
     if (!is_null($object->getModifications())) {
         if (!$this->serializer instanceof NormalizerInterface) {
             throw new \LogicException('Cannot normalize attribute "Mods" because injected serializer is not a normalizer.');
         }
         $modifications = array();
         foreach ($object->getModifications() as $key => $modification) {
             $modification = $this->normalize($modification, $format, $context);
             $modifications[$key] = $modification;
         }
         if (!empty($modifications)) {
             $data[self::MODS] = $modifications;
         }
     }
     return $data;
 }
Example #29
0
 /**
  * function to build location block
  *
  * @param object $form the object of the form (QF Object)
  * @param int $maxLocationBlocks no of location blocks
  *
  * @static 
  * @access public
  */
 function &buildLocationBlock(&$form, $maxLocationBlocks)
 {
     $location = array();
     for ($locationId = 1; $locationId <= $maxLocationBlocks; $locationId++) {
         $location[$locationId]['location_type_id'] = $form->addElement('select', "location[{$locationId}][location_type_id]", null, CRM_Core_PseudoConstant::locationType());
         $location[$locationId]['is_primary'] = $form->addElement('checkbox', "location[{$locationId}][is_primary]", ts('Primary location for this contact'), ts('Primary location for this contact'), array('onchange' => "location_is_primary_onclick('" . $form->getName() . "', {$locationId}, {$maxLocationBlocks});"));
         $location[$locationId]['name'] = $form->addElement('text', "location[{$locationId}][name]", ts('Location Name'), CRM_Core_PseudoConstant::locationType());
         CRM_Contact_Form_Address::buildAddressBlock($form, $location, $locationId);
         CRM_Contact_Form_Phone::buildPhoneBlock($form, $location, $locationId, CRM_CONTACT_FORM_LOCATION_BLOCKS);
         CRM_Contact_Form_Email::buildEmailBlock($form, $location, $locationId, CRM_CONTACT_FORM_LOCATION_BLOCKS);
         CRM_Contact_Form_IM::buildIMBlock($form, $location, $locationId, CRM_CONTACT_FORM_LOCATION_BLOCKS);
         CRM_Core_ShowHideBlocks::linksForArray($form, $locationId, $maxLocationBlocks, "location", '', '');
     }
     return $location;
 }
 /**
  * Add a local article to the global watch list.
  *
  * @access	public
  * @param	object	WikiPage object.
  * @return	boolean Success
  */
 public function addArticle(WikiPage $article)
 {
     global $wgSitename, $wgMetaNamespace, $wgServer, $wgScriptPath;
     if (!$this->siteKey) {
         return false;
     }
     $articleTitle = $article->getTitle();
     if ($articleTitle->getArticleID() == 0) {
         return false;
     }
     $data = ['user' => ['mName' => $this->user->getName(), 'global_id' => \CurseAuthUser::getInstance($this->user)->getId()], 'article' => ['mTextform' => $articleTitle->getText(), 'mNamespace' => $articleTitle->getNamespace(), 'mArticleID' => $articleTitle->getArticleID(), 'mLatestID' => $articleTitle->getLatestRevID()], 'site' => ['wiki_name' => $wgSitename, 'wiki_meta_name' => $wgMetaNamespace, 'wiki_domain' => $wgServer, 'url_prefix' => wfExpandUrl($wgServer . $wgScriptPath)]];
     $list = $this->getList();
     $list[$this->siteKey][$data['article']['mArticleID']] = $data;
     return $this->setList($list);
 }