Example #1
0
 /**
  * @param object $model
  * @param bool $strict
  *
  * @return string
  */
 protected function getModelId($model, $strict = true)
 {
     if ($strict && false == $model->getId()) {
         throw new \LogicException('The id is missing');
     }
     return (string) $model->getId();
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function getEntityId()
 {
     if ($this->entity !== null && $this->entity->getId()) {
         return $this->entity->getId();
     }
     return $this->entityId;
 }
Example #3
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];
 }
Example #4
0
 /**
  * Setup an Event
  *
  * Phalcon event to make sure client sends a valid message
  * @return FALSE|void
  */
 public function handleEvent()
 {
     $this->attach('micro', function ($event, $app) {
         if ($event->getType() == 'beforeExecuteRoute') {
             $data = $this->msg->getData();
             ksort($data);
             // Need to refactor this
             $message = $this->msg->getTime() . $this->msg->getId() . implode($data);
             $serverHash = hash_hmac('sha256', $message, $this->privateKey);
             $clientHash = $this->msg->getHash();
             $allowed = $clientHash === $serverHash ?: false;
             $method = strtolower($app->router->getMatchedRoute()->getHttpMethods());
             $unAuthenticated = $app->getUnauthenticated();
             if (isset($unAuthenticated[$method])) {
                 $unAuthenticated = array_flip($unAuthenticated[$method]);
                 if (isset($unAuthenticated[$app->router->getMatchedRoute()->getPattern()])) {
                     $allowed = true;
                 }
             }
             if (!$allowed) {
                 $app->response->setStatusCode(401, "Unauthorized");
                 $app->response->setContent("Access denied");
                 $app->response->send();
                 return false;
             }
         }
     });
 }
 /**
  * 
  * @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();
 }
 /**
  *  Recursively build the navigation elements from a certain level
  *
  * @param array $elements An array of wrapped objects (NavigationItem)
  * @param null  $parent   The parent Element (for recursivity)
  * @param int   $level    The actual level (for recursivity)
  *
  * @throws \Exception
  *
  * @return array
  */
 private function buildLevel($elements, $parent = null, $level = 1)
 {
     foreach ($elements as $key => $element) {
         if (false == $element instanceof NavigationItemInterface) {
             throw new \Exception(get_class($element) . ' need to implement the NavigationItemInterface to be usable in the ' . get_class($this));
         }
         if (!$element->getParent()) {
             $element->setParent($parent);
         }
         $element->setSelected(get_class($element->getEntity()) == get_class($this->selectedElement) && $element->getEntity()->getId() == $this->selectedElement->getId());
         // TODO Remplacer le 1 par le ID de la section 'Accueil'
         if (get_class($element->getEntity()) == 'Unifik\\Backend\\SectionBundle\\Entity\\Section' && $element->getEntity()->getId() == 1 && $element->isSelected() && $this->container->get('unifik_system.core')->getCurrentAppName() != 'backend') {
             unset($elements[$key]);
             continue;
         }
         // This is the currently selected element
         // We set every parents of the currently selected element as selected from the current level back to level 1
         if ($element->isSelected()) {
             $parent = $element->getParent();
             while ($parent && $parent->getEntity()->getId()) {
                 $parent->setSelected(true);
                 $parent = $parent->getParent();
             }
         }
         if (!$this->maxLevel || $level < $this->maxLevel) {
             // This element have some children, we start the same process on the children collection
             if ($element->hasChildren()) {
                 $this->buildLevel($element->getChildren(), $element, $level + 1);
             }
         }
     }
     return $elements;
 }
Example #7
0
    /**
     * Sets up HTML to be injected into the form's bottom
     *
     * @param   object  $params     params
     * @param   object  $formModel  form model
     *
     * @return void
     */
    public function getBottomContent($params, $formModel)
    {
        $user = JFactory::getUser();
        if ($user->get('id') == 0) {
            $this->html = JText::_('PLG_CRON_NOTIFICATION_SIGN_IN_TO_RECEIVE_NOTIFICATIONS');
            return;
        }
        if ($params->get('send_mode') == '1') {
            return;
        }
        $opts = new stdClass();
        $opts->listid = $formModel->getListModel()->getId();
        $opts->formid = $formModel->getId();
        $opts->rowid = $formModel->_rowId;
        $opts->senderBlock = JRequest::getCmd('view') == 'form' ? 'form_' : 'details_';
        $opts->senderBlock .= $formModel->getId();
        $opts = json_encode($opts);
        $id = uniqid('fabrik_notification');
        if ($params->get('notification_ajax', 0) == 1) {
            FabrikHelperHTML::script('components/com_fabrik/plugins/form/notification/notify.js');
            $script = "head.ready(function() {\n\t\t\t\tvar notify = new Notify('{$id}', {$opts});\n \t\t\t});";
            FabrikHelperHTML::addScriptDeclaration($script);
        }
        // See if the checkbox should be checked
        $db = FabrikWorker::getDbo();
        $ref = $this->getRef($formModel->getListModel()->getId());
        $query = $db->getQuery(true);
        $query->select('COUNT(id)')->from('#__{package}_notification')->where('user_id = ' . (int) $user->get('id') . ' AND reference = ' . $ref);
        $db->setQuery($query);
        $found = $db->loadResult();
        $checked = $found ? 'checked="checked"' : '';
        $this->html = '
		<label><input id="' . $id . '" ' . $checked . ' type="checkbox" name="fabrik_notification" class="input" value="1"  />
		 ' . JText::_('PLG_CRON_NOTIFICATION_NOTIFY_ME') . '</label>';
    }
Example #8
0
 /**
  * @param string $entityType
  * @param object $entity
  * @return object
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute($entityType, $entity)
 {
     if ($entity->getId()) {
         $stores = $this->resourcePage->lookupStoreIds((int) $entity->getId());
         $entity->setData('store_id', $stores);
     }
     return $entity;
 }
 /**
  * Get settings and module id and starts import process.
  *
  * Run module settings import logic only if it has settings array
  * On empty settings array, it will remove the settings.
  *
  * @param object $module Module or Theme Object
  */
 public function run($module)
 {
     $moduleSettings = $module->getInfo('settings');
     $isTheme = $this->isTheme($module->getId());
     if (!$isTheme || $isTheme && is_array($moduleSettings)) {
         $this->addModuleSettings($moduleSettings, $module->getId());
     }
 }
Example #10
0
 /**
  * Returns all active stays
  *
  * @return array
  */
 function getActive()
 {
     $res = $this->db->query('SELECT id, indkvartering_key, price FROM kortkursus_x_indkvartering WHERE kursus_id = ' . $this->course->getId() . ' ORDER BY indkvartering_key ASC');
     if (PEAR::isError($res)) {
         throw new Exception($res->getUserInfo());
     }
     return $res->fetchAll(MDB2_FETCHMODE_ASSOC);
 }
/**
 * 	Displays a EasyContactFormsUsers manageMain view record
 *
 * @param object $view
 * 	the EasyContactFormsUsers manageMain view object
 * @param object $obj
 * 	a db object
 * @param int $i
 * 	record index
 * @param array $map
 * 	request data
 */
function getUsersManageMainViewRow($view, $obj, $i, $map)
{
    $jsconf = json_decode(stripslashes($map['a']));
    $args = $jsconf->ca[0];
    $obj->addjsconfig = (object) array();
    $obj->addjsconfig->viewTarget = $args->mt . 'Div';
    $obj->addjsconfig->t = $args->mt;
    $obj->addjsconfig->m = 'mtmview';
    $obj->addjsconfig->m2 = 'addRow';
    $obj->addjsconfig->n = $args->t;
    $obj->addjsconfig->a = array();
    $obj->addjsconfig->a[] = (object) array('fld' => $args->n, 'oid' => $obj->getId());
    $obj->addjsconfig->a[] = (object) array('fld' => $args->fld, 'oid' => $args->oid);
    $obj->addjsconfig->a = json_encode($obj->addjsconfig->a);
    $obj->addjsconfig = EasyContactFormsUtils::toJs($obj->addjsconfig);
    $obj->Add = "onclick='ufo.link({$obj->addjsconfig}, {$view->jsconfig})'";
    $obj->Description = array();
    $obj->Description[] = $obj->get('Name');
    $obj->Description[] = $obj->get('Description');
    $obj->Description = EasyContactFormsUtils::vImplode(' ', $obj->Description);
    ?>
  <tr>
    <td class='firstcolumn'>
      <a id='<?php 
    echo $obj->elId('Add', $obj->getId());
    ?>
' title='<?php 
    echo EasyContactFormsT::get('Add');
    ?>
' href='javascript:;' class='icon_button_add ufo-mtmlink-button' <?php 
    echo $obj->Add;
    ?>
></a>
    </td>
    <td>
      <?php 
    echo $obj->get('id');
    ?>
    </td>
    <td>
      <a id='<?php 
    echo $obj->elId('Description', $obj->getId());
    ?>
' class='ufo-id-link' onclick='ufo.redirect({m:"show", oid:"<?php 
    echo $obj->get('id');
    ?>
", t:"Users"})' onmouseover='ufo.showInfo({t:"Users", m2:"getUserASList", oid:<?php 
    echo $obj->get('id');
    ?>
, m:"ajaxsuggest"}, this)'>
        <?php 
    echo $obj->Description;
    ?>
      </a>
    </td>
  </tr>
	<?php 
}
 /**
  * Constructor
  *
  * @return void
  */
 public function __construct(&$network)
 {
     $db = AbstractDb::getObject();
     // Init network
     $this->_network = $network;
     $this->_csv_document = "";
     // Query the database, sorting by node name
     $db->execSql("SELECT *, (CURRENT_TIMESTAMP-last_heartbeat_timestamp) AS since_last_heartbeat, EXTRACT(epoch FROM creation_date) as creation_date_epoch, CASE WHEN ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) < interval '5 minutes') THEN true ELSE false END AS is_up FROM nodes WHERE network_id = '" . $db->escapeString($this->_network->getId()) . "' AND (node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE') ORDER BY lower(name)", $this->_nodes, false);
 }
Example #13
0
 /**
  * @param object $entity
  * @param array $arguments
  * @return object
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute($entity, $arguments = [])
 {
     if ($entity->getId()) {
         $stores = $this->resourceBlock->lookupStoreIds((int) $entity->getId());
         $entity->setData('store_id', $stores);
         $entity->setData('stores', $stores);
     }
     return $entity;
 }
Example #14
0
 /**
  * {@inheritdoc}
  *
  * @param object $entity
  * @param bool   $flush
  */
 public function deleteEntity($entity, $flush = true)
 {
     // Null parents of associated events first
     $q = $this->getEntityManager()->getConnection()->createQueryBuilder();
     $q->update(MAUTIC_TABLE_PREFIX . 'campaign_events')->set('parent_id', ':null')->setParameter('null', null)->where('campaign_id = ' . $entity->getId())->execute();
     // Delete events
     $q = $this->getEntityManager()->getConnection()->createQueryBuilder();
     $q->delete(MAUTIC_TABLE_PREFIX . 'campaign_events')->where('campaign_id = ' . $entity->getId())->execute();
     parent::deleteEntity($entity, $flush);
 }
Example #15
0
 /**
  * Before the record is stored, this plugin will see if it should process
  * and if so store the form data in the session.
  * @param object $params
  * @param object $formModel
  * @return bool
  */
 function onBeforeStore(&$params, &$formModel)
 {
     if (JRequest::getInt('fabrik_ignorevalidation') === 1 || JRequest::getInt('fabrik_ajax') === 1) {
         //saving via inline edit - dont want to confirm
         return true;
     }
     $this->runAway = false;
     $this->data = $formModel->_formData;
     if (!$this->shouldProcess('confirmation_condition')) {
         $this->clearSession($formModel->getId());
         return true;
     }
     if (JRequest::getVar('fabrik_confirmation') == 2) {
         //if we were already on the confirmation page
         // return and set to 2 to ignore?
         // $$$ hugh - I don't think it really matters,
         // 'cos getBottomContent isn't going to be called again
         JRequest::setVar('fabrik_confirmation', 1);
         return true;
     }
     // $$$ set flag to stop subsequent onBeforeStore plug-ins from running
     $this->runAway = true;
     // Initialize some variables
     $form = $formModel->getForm();
     //save the posted form data to the form session, for retrival later
     $sessionModel = JModel::getInstance('Formsession', 'FabrikFEModel');
     $sessionModel->setFormId($formModel->getId());
     $rowid = JRequest::getVar('rowid', 0);
     $sessionModel->setRowId($rowid);
     $sessionModel->savePage($formModel);
     // tell the form model that it's data is loaded from the session
     $session = JFactory::getSession();
     $session->set('com_fabrik.form.' . $formModel->getId() . '.session.on', true);
     $session->set('com_fabrik.form.' . $formModel->getId() . '.session.hash', $sessionModel->getHash());
     //set an error so we can reshow the same form for confirmation purposes
     $formModel->_arErrors['confirmation_required'] = true;
     $form->error = JText::_('PLG_FORM_CONFIRMATION_PLEASE_CONFIRM_YOUR_DETAILS');
     $formModel->_editable = false;
     //clear out unwanted buttons
     $formParams = $formModel->getParams();
     $formParams->set('reset_button', 0);
     $formParams->set('goback_button', 0);
     //the user has posted the form we need to make a note of this
     //for our getBottomContent() function
     JRequest::setVar('fabrik_confirmation', 1);
     //set the element access to read only??
     $groups = $formModel->getGroupsHiarachy();
     foreach ($groups as $groupModel) {
         $elementModels = $groupModel->getPublishedElements();
         foreach ($elementModels as $elementModel) {
             $elementModel->getElement()->access = 26;
         }
     }
     return false;
 }
Example #16
0
 /**
  * @param object $element
  * @return AbstractForm
  */
 public function setElement($element)
 {
     if ($element instanceof HtmlScript) {
         if (is_null($element->getId())) {
             $this->_elements[] = $element;
         } else {
             $this->_elements[$element->getId()] = $element;
         }
     } else {
         $this->_elements[$element->getId()] = $element;
     }
     return $this;
 }
 /**
  * Save the teammate
  * @param object $teammate
  * @return object
  */
 public function save($teammate)
 {
     $teammateData = array('firstname' => $teammate->getFirstname(), 'lastname' => $teammate->getLastname(), 'email' => $teammate->getEmail(), 'phone' => $teammate->getPhone(), 'image' => $teammate->getImage());
     if ($teammate->getId()) {
         $this->db->update('teammate', $teammateData, array('id' => $teammate->getId()));
     } else {
         $this->db->insert('teammate', $teammateData);
         // Get the id of the newly created artist and set it on the entity.
         $id = $this->db->lastInsertId();
         $teammate->setId($id);
     }
     return $teammate;
 }
Example #18
0
 /**
  * Tests creating and deleting a comment.
  *
  * @return void
  */
 public function testCreateAndDeleteComment()
 {
     $tid = $this->contents->getId();
     $title = 'hallo';
     $cid = $this->contents->getId();
     $user = '******';
     $comment = array('user' => $user, 'time' => time(), 'comment' => 'foo bar baz');
     $this->contents->createComment($this->forum, $tid, $title, $cid, $comment);
     $actual = $this->getComment($this->forum, $tid, $cid);
     $this->assertEquals($comment, $actual);
     $this->contents->deleteComment($this->forum, $tid, $cid, $user);
     $actual = $this->getComment($this->forum, $tid, $cid);
     $this->assertEmpty($actual);
 }
/**
 * 	Displays a EasyContactFormsCustomForms manageMain view record
 *
 * @param object $view
 * 	the EasyContactFormsCustomForms manageMain view object
 * @param object $obj
 * 	a db object
 * @param int $i
 * 	record index
 * @param array $map
 * 	request data
 */
function getCustomFormsManageMainViewRow($view, $obj, $i, $map)
{
    $jsconf = json_decode(stripslashes($map['a']));
    $args = $jsconf->ca[0];
    $obj->addjsconfig = (object) array();
    $obj->addjsconfig->viewTarget = $args->mt . 'Div';
    $obj->addjsconfig->t = $args->mt;
    $obj->addjsconfig->m = 'mtmview';
    $obj->addjsconfig->m2 = 'addRow';
    $obj->addjsconfig->n = $args->t;
    $obj->addjsconfig->a = array();
    $obj->addjsconfig->a[] = (object) array('fld' => $args->n, 'oid' => $obj->getId());
    $obj->addjsconfig->a[] = (object) array('fld' => $args->fld, 'oid' => $args->oid);
    $obj->addjsconfig->a = json_encode($obj->addjsconfig->a);
    $obj->addjsconfig = EasyContactFormsUtils::toJs($obj->addjsconfig);
    $obj->id = "onclick='ufo.link({$obj->addjsconfig}, {$view->jsconfig})'";
    ?>
  <tr>
    <td class='firstcolumn'>
      <a id='<?php 
    echo $obj->elId('id', $obj->getId());
    ?>
' title='<?php 
    echo EasyContactFormsT::get('Add');
    ?>
' href='javascript:;' class='icon_button_add ufo-mtmlink-button' <?php 
    echo $obj->id;
    ?>
></a>
    </td>
    <td>
      <?php 
    echo $obj->get('id');
    ?>
    </td>
    <td>
      <a onclick='ufo.redirect({m:"show", oid:"<?php 
    echo $obj->get('id');
    ?>
", t:"CustomForms"})'>
        <?php 
    EasyContactFormsIHTML::echoStr($obj->get('Description'));
    ?>
      </a>
    </td>
  </tr>
	<?php 
}
 /**
  *	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 #21
0
 /**
  * Constructeur du groupe.
  * 
  * @param int $id
  * @param object $Fundation
  * @param string $name
  * @param int $open
  * @param int $public
  */
 public function __construct($id = 0, &$Fundation = 0, $name = 0, $open = 0, $isPublic = 0)
 {
     $this->db = Db_buckutt::getInstance();
     //Création de groupe
     if ($id == 0) {
         $this->db->query("INSERT INTO t_group_grp (grp_name, grp_open, grp_public, fun_id) VALUES('%s', '%u', '%u', '%u');", array($name, $open, $isPublic, $Fundation->getId()));
         if ($this->db->affectedRows() == 1) {
             $this->id = $this->db->insertId();
             $this->name = $name;
             $this->open = $open;
             $this->isPublic = $isPublic;
             $this->state = 1;
         } else {
             $this->state = 400;
         }
     } else {
         $this->id = $id;
         $don = $this->db->fetchArray($this->db->query("SELECT grp_name, grp_open, grp_public FROM t_group_grp WHERE grp_id = '%u' AND grp_removed = '0';", array($this->id)));
         if ($this->db->affectedRows() == 1) {
             $this->name = $don['grp_name'];
             $this->open = $don['grp_open'];
             $this->isPublic = $don['grp_public'];
             $this->state = 1;
         } else {
             $this->state = 464;
         }
         return $this->state;
     }
 }
Example #22
0
 /**
  * Extract values from an object
  *
  * @param  object $object
  *
  * @return array
  */
 public function extract($object)
 {
     if (!$object instanceof Post) {
         return array();
     }
     return array('id' => $object->getId(), 'title' => $object->getTitle(), 'slug' => $object->getSlug(), 'content' => $object->getContent(), 'created' => $object->getCreated());
 }
Example #23
0
 /**
  * @param  object|null $value
  * @return int|null
  */
 public function extract($value)
 {
     if ($value === null) {
         return null;
     }
     return $value->getId();
 }
Example #24
0
 /**
  * @param object $entity
  *
  * @return integer|null
  */
 protected function getEntityId($entity)
 {
     if ($entity) {
         return $entity->getId();
     }
     return null;
 }
/**
 * 	Displays a EasyContactFormsCustomFormEntryFiles detailedMain view
 * 	record
 *
 * @param object $view
 * 	the EasyContactFormsCustomFormEntryFiles detailedMain view object
 * @param object $obj
 * 	a db object
 * @param int $i
 * 	record index
 * @param array $map
 * 	request data
 */
function getCustomFormEntryFilesDetailedMainViewRow($view, $obj, $i, $map)
{
    $obj->File = array('doctype' => 'CustomFormEntryFiles', 'docid' => $obj->get('id'), 'field' => 'File', 'tag' => 'a', 'content' => EasyContactFormsT::get('Download'));
    ?>
  <tr class='ufohighlight <?php 
    EasyContactFormsIHTML::getTrSwapClassName($i);
    ?>
'>
    <td class='firstcolumn'>
      <input type='checkbox' id='<?php 
    echo $view->idJoin('cb', $obj->getId());
    ?>
' value='off' class='ufo-deletecb' onchange='this.value=(this.checked)?"on":"off";'/>
    </td>
    <td>
      <?php 
    echo $obj->get('id');
    ?>
    </td>
    <td>
      <?php 
    echo $obj->get('Description');
    ?>
    </td>
    <td>
      <?php 
    EasyContactFormsIHTML::getFileDownloadLink($obj->File);
    ?>
    </td>
  </tr>
	<?php 
}
 /**
  * @param object $entity
  *
  * @return null|int
  */
 public function transform($entity)
 {
     if (null === $entity) {
         return;
     }
     return $entity->getId();
 }
Example #27
0
 /**
  * Return true if both user and object respects all the rules conditions
  * If the objectId is null, policy rules about its attributes will be ignored
  * In case of mismatch between attributes and expected values,
  * an array with the concerned attributes slugs will be returned.
  *
  * Available options are :
  * * dynamic_attributes: array
  * * cache_result: boolean
  * * cache_ttl: integer
  * * cache_driver: string
  *
  * Available cache drivers are :
  * * memory
  *
  * @param string $ruleName
  * @param object $user
  * @param object $resource
  * @param array $options
  * @return boolean|array
  */
 public function enforce($ruleName, $user, $resource = null, $options = [])
 {
     // If there is dynamic attributes, we pass them to the comparison manager
     // When a comparison will be performed, the passed values will be retrieved and used
     if (isset($options['dynamic_attributes'])) {
         $this->comparisonManager->setDynamicAttributes($options['dynamic_attributes']);
     }
     // Retrieve cache value for the current rule and values if cache item is valid
     if (($cacheResult = isset($options['cache_result']) && $options['cache_result'] === true) === true) {
         $cacheItem = $this->cacheManager->getItem("{$ruleName}-{$user->getId()}-" . ($resource !== null ? $resource->getId() : ''), isset($options['cache_driver']) ? $options['cache_driver'] : null, isset($options['cache_ttl']) ? $options['cache_ttl'] : null);
         // We check if the cache value s valid before returning it
         if (($cacheValue = $cacheItem->get()) !== null) {
             return $cacheValue;
         }
     }
     $policyRule = $this->policyRuleManager->getRule($ruleName, $user, $resource);
     // For each policy rule attribute, we retrieve the attribute value and proceed configured extra data
     foreach ($policyRule->getPolicyRuleAttributes() as $pra) {
         $attribute = $pra->getAttribute();
         $attribute->setValue($this->attributeManager->retrieveAttribute($attribute, $user, $resource));
         if (count($pra->getExtraData()) > 0) {
             $this->processExtraData($pra, $user, $resource);
         }
         $this->comparisonManager->compare($pra);
     }
     // The given result could be an array of rejected attributes or true
     // True means that the rule is correctly enforced for the given user and resource
     $result = $this->comparisonManager->getResult();
     if ($cacheResult) {
         $cacheItem->set($result);
         $this->cacheManager->save($cacheItem);
     }
     return $result;
 }
Example #28
0
 /**
  * Returns view to index with a locked out message
  *
  * @param array  $postActionVars
  * @param object $entity
  * @param string $model
  * @param bool   $batch Flag if a batch action is being performed
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse|array
  */
 protected function isLocked($postActionVars, $entity, $model, $batch = false)
 {
     $date = $entity->getCheckedOut();
     $returnUrl = !empty($postActionVars['returnUrl']) ? urlencode($postActionVars['returnUrl']) : urlencode($this->generateUrl('mautic_dashboard_index'));
     $override = '';
     $modelClass = $this->factory->getModel($model);
     $nameFunction = $modelClass->getNameGetter();
     if ($this->factory->getUser()->isAdmin()) {
         $override = $this->get('translator')->trans('mautic.core.override.lock', array('%url%' => $this->generateUrl('mautic_core_form_action', array('objectAction' => 'unlock', 'objectModel' => $model, 'objectId' => $entity->getId(), 'returnUrl' => $returnUrl, 'name' => urlencode($entity->{$nameFunction}())))));
     }
     $flash = array('type' => 'error', 'msg' => 'mautic.core.error.locked', 'msgVars' => array("%name%" => $entity->{$nameFunction}(), "%user%" => $entity->getCheckedOutByUser(), '%contactUrl%' => $this->generateUrl('mautic_user_action', array('objectAction' => 'contact', 'objectId' => $entity->getCheckedOutBy(), 'entity' => $model, 'id' => $entity->getId(), 'subject' => 'locked', 'returnUrl' => $returnUrl)), '%date%' => $date->format($this->factory->getParameter('date_format_dateonly')), '%time%' => $date->format($this->factory->getParameter('date_format_timeonly')), '%datetime%' => $date->format($this->factory->getParameter('date_format_full')), '%override%' => $override));
     if ($batch) {
         return $flash;
     }
     return $this->postActionRedirect(array_merge($postActionVars, array('flashes' => array($flash))));
 }
 /**
  * Transforms an object (object) to a string (id).
  *
  * @param object|null $object
  *
  * @return string
  */
 public function transform($object)
 {
     if (null === $object) {
         return '';
     }
     return $object->getId();
 }
Example #30
0
 /**
  * Add newsletter products (#559 only if we have user we can assign this info),
  * adds products which fit to the last order of assigned user.
  *
  * @param oxview $oView            view object to store view data
  * @param bool   $blPerfLoadAktion perform option load actions
  */
 protected function _assignProducts($oView, $blPerfLoadAktion = false)
 {
     if ($blPerfLoadAktion) {
         $oArtList = oxNew('oxArticleList');
         $oArtList->loadActionArticles('OXNEWSLETTER');
         $oView->addTplParam('articlelist', $oArtList);
     }
     if ($this->_oUser->getId()) {
         $oArticle = oxNew('oxArticle');
         $sArticleTable = $oArticle->getViewName();
         // add products which fit to the last order of this user
         $sSelect = "select {$sArticleTable}.* from oxorder left join oxorderarticles on oxorderarticles.oxorderid = oxorder.oxid";
         $sSelect .= " left join {$sArticleTable} on oxorderarticles.oxartid = {$sArticleTable}.oxid";
         $sSelect .= " where " . $oArticle->getSqlActiveSnippet();
         $sSelect .= " and oxorder.oxuserid = '" . $this->_oUser->getId() . "' order by oxorder.oxorderdate desc limit 1";
         if ($oArticle->assignRecord($sSelect)) {
             $oSimList = $oArticle->getSimilarProducts();
             if ($oSimList && $oSimList->count()) {
                 $oView->addTplParam('simlist', $oSimList);
                 $iCnt = 0;
                 foreach ($oSimList as $oArt) {
                     $oView->addTplParam("simarticle{$iCnt}", $oArt);
                     $iCnt++;
                 }
             }
         }
     }
 }