/**
 * Handle on inline tabs event
 *
 * @param NamedList $tabs
 * @param ApplicationObject $object
 * @param User $logged_user
 * @param string $interface
 * @return null
 */
function ac_gitolite_handle_on_inline_tabs(&$tabs, &$object, &$logged_user, $interface)
{
    if ($object instanceof User) {
        if ($object->getId() == $logged_user->getId() || $logged_user->isAdministrator() || $logged_user->isPeopleManager()) {
            $tabs->add('view_keys', array('title' => lang('Public Keys'), 'url' => Router::assemble('get_public_keys', array('company_id' => $object->getCompanyId(), 'user_id' => $object->getId()))));
        }
    }
    // if User
}
    protected function getApplicationCustomParamater($paramKey)
    {
        $paramValue = $this->applicationLocalized->getCustomParameter($paramKey);

        if (empty($paramValue) && $this->applicationObject) {
            $paramValue = $this->applicationObject->getCustomParameter($paramKey);
        }

        return $paramValue;
    }
Exemplo n.º 3
0
function frosso_estimated_cost_handle_on_after_object_save(ApplicationObject &$object)
{
    if ($object instanceof Milestone && !$object instanceof RemediaMilestone) {
        if (isset($_POST['milestone']['custom_field_1']) && $_POST['milestone']['custom_field_1'] != '') {
            $remedia_mil = new RemediaMilestone($object->getId());
            $remedia_mil->customFields()->setValue('custom_field_1', $_POST['milestone']['custom_field_1']);
            $remedia_mil->setNew(false);
            $remedia_mil->save();
        }
    }
}
    /**
     * @return bool
     */
    public function canRead()
    {
        if( !$this->isFull || !$this->user() )
            return true;

        if( $this->isFull )
            return ( in_array( $this->_applicationFull->attribute('id'), CountryApplicationLibrary::fetchAuthorizedApplicationIds() ) );
    }
    /**
     * Returns string of any additional CSS classes to apply
     *
     * @return string
     **/
    protected function additionalClasses()
    {
        $typeIdentifier = $this->applicationObject->attribute( 'application_type' )->attribute( 'type_identifier' );

        if ( $typeIdentifier == 'jama-network' )
            return ' item-jama';

        return '';
    }
    /**
     * @return PermissionHandlerBase
     * @param ApplicationLocalized $applicationLocalized
     * @param ApplicationObject $applicationObject
     */
    public static function create(ApplicationLocalized $applicationLocalized, ApplicationObject $applicationObject)
    {
        $permissionHandlerIdentifier = $applicationLocalized->getCustomParameter('PermissionHandler');

        if (empty($permissionHandlerIdentifier))
        {
            $permissionHandlerIdentifier = $applicationObject->getCustomParameter('PermissionHandler');
        }

        if (empty($permissionHandlerIdentifier))
        {
            $permissionHandlerIdentifier = self::DEFAULT_PERMISSION_HANDLER;
        }

        /* @var $permissionHandler PermissionHandlerBase */
        $permissionHandler = new $permissionHandlerIdentifier();
        $permissionHandler->setApplicationObject($applicationObject);
        $permissionHandler->setApplicationLocalized($applicationLocalized);

        return $permissionHandler;
    }
    /**
     * @return string[]
     */
    public function webtrendsParams()
    {
        $r = array(
            'cg_n' => $this->applicationObject->attribute( 'webtrends_cg_n' ),
            'ti'   => $this->applicationObject->attribute( 'webtrends_ti' ),
        );

        if( $this->attribute( 'webtrends_cg_n' ) )
            $r['cg_n'] = $this->attribute( 'webtrends_cg_n' );

        if( $this->attribute( 'webtrends_ti' ) )
            $r['ti'] = $this->attribute( 'webtrends_ti' );

        return $r;
    }
    /**
     * @param string $key
     * @return mixed
     */
    public function getCustomParameter($key)
    {
        $custom = null;

        if (!empty($this->applicationLocalized) )
        {
            $custom = $this->applicationLocalized->getCustomParameter($key);
        }

        if ( $custom === false && !empty($this->applicationObject) )
        {
            $custom = $this->applicationObject->getCustomParameter($key);
        }

        return $custom;
    }
 /**
  * Set value of specific field
  *
  * @param string $name
  * @param mided $value
  * @return mixed
  */
 function setFieldValue($name, $value)
 {
     $real_name = $this->realFieldName($name);
     $set = $value;
     switch ($real_name) {
         case 'id':
             $set = intval($value);
             break;
         case 'mailbox_id':
             $set = intval($value);
             break;
         case 'state':
             $set = intval($value);
             break;
         case 'response':
             $set = strval($value);
             break;
         case 'sender':
             $set = strval($value);
             break;
         case 'subject':
             $set = strval($value);
             break;
         case 'incoming_mail_id':
             $set = intval($value);
             break;
         case 'project_object_id':
             $set = intval($value);
             break;
         case 'created_on':
             $set = datetimeval($value);
             break;
     }
     // switch
     return parent::setFieldValue($real_name, $set);
 }
 public function htmlBuildResult()
 {
     $this->pushResult('baseUrl'     , eZINI::instance()->variable( 'SiteAccessSettings', 'BaseUrl' ));
     $this->pushResult('children'    , ApplicationObject::fetchByParent($this->applicationObject()->id));
     $this->pushResult('application' , $this->applicationObject());
 }
 /**
  * Set value of specific field
  *
  * @param string $name
  * @param mided $value
  * @return mixed
  */
 function setFieldValue($name, $value)
 {
     $real_name = $this->realFieldName($name);
     $set = $value;
     switch ($real_name) {
         case 'id':
             $set = intval($value);
             break;
         case 'parent_id':
             $set = intval($value);
             break;
         case 'message':
             $set = strval($value);
             break;
         case 'created_by_id':
             $set = intval($value);
             break;
         case 'created_by_name':
             $set = strval($value);
             break;
         case 'created_by_email':
             $set = strval($value);
             break;
         case 'created_on':
             $set = datetimeval($value);
             break;
         case 'last_update_on':
             $set = datetimeval($value);
             break;
     }
     // switch
     return parent::setFieldValue($real_name, $set);
 }
 /**
  * Set value of specific field
  *
  * @param string $name
  * @param mided $value
  * @return mixed
  */
 function setFieldValue($name, $value)
 {
     $real_name = $this->realFieldName($name);
     $set = $value;
     switch ($real_name) {
         case 'repository_id':
             $set = intval($value);
             break;
         case 'repository_user':
             $set = strval($value);
             break;
         case 'user_id':
             $set = intval($value);
             break;
     }
     // switch
     return parent::setFieldValue($real_name, $set);
 }
 /**
  * Set value of specific field
  *
  * @param string $name
  * @param mided $value
  * @return mixed
  */
 function setFieldValue($name, $value)
 {
     $real_name = $this->realFieldName($name);
     $set = $value;
     switch ($real_name) {
         case 'id':
             $set = intval($value);
             break;
         case 'invoice_id':
             $set = intval($value);
             break;
         case 'position':
             $set = intval($value);
             break;
         case 'tax_rate_id':
             $set = intval($value);
             break;
         case 'description':
             $set = strval($value);
             break;
         case 'quantity':
             $set = floatval($value);
             break;
         case 'unit_cost':
             $set = floatval($value);
             break;
     }
     // switch
     return parent::setFieldValue($real_name, $set);
 }
 /**
  * Set value of specific field
  *
  * @param string $name
  * @param mided $value
  * @return mixed
  */
 function setFieldValue($name, $value)
 {
     $real_name = $this->realFieldName($name);
     $set = $value;
     switch ($real_name) {
         case 'name':
             $set = strval($value);
             break;
         case 'module':
             $set = strval($value);
             break;
         case 'subject':
             $set = strval($value);
             break;
         case 'body':
             $set = strval($value);
             break;
         case 'variables':
             $set = strval($value);
             break;
     }
     // switch
     return parent::setFieldValue($real_name, $set);
 }
 /**
  * Set value of specific field
  *
  * @param string $name
  * @param mided $value
  * @return mixed
  */
 function setFieldValue($name, $value)
 {
     $real_name = $this->realFieldName($name);
     $set = $value;
     switch ($real_name) {
         case 'id':
             $set = intval($value);
             break;
         case 'name':
             $set = strval($value);
             break;
         case 'locale':
             $set = strval($value);
             break;
     }
     // switch
     return parent::setFieldValue($real_name, $set);
 }
 /**
  * Set value of specific field
  *
  * @param string $name
  * @param mided $value
  * @return mixed
  */
 function setFieldValue($name, $value)
 {
     $real_name = $this->realFieldName($name);
     $set = $value;
     switch ($real_name) {
         case 'id':
             $set = intval($value);
             break;
         case 'project_id':
             $set = intval($value);
             break;
         case 'object_type':
             $set = strval($value);
             break;
         case 'mailbox':
             $set = strval($value);
             break;
         case 'username':
             $set = strval($value);
             break;
         case 'password':
             $set = strval($value);
             break;
         case 'host':
             $set = strval($value);
             break;
         case 'from_name':
             $set = strval($value);
             break;
         case 'from_email':
             $set = strval($value);
             break;
         case 'type':
             $set = strval($value);
             break;
         case 'port':
             $set = intval($value);
             break;
         case 'security':
             $set = strval($value);
             break;
         case 'last_status':
             $set = intval($value);
             break;
         case 'enabled':
             $set = intval($value);
             break;
         case 'accept_all_registered':
             $set = intval($value);
             break;
         case 'accept_anonymous':
             $set = intval($value);
             break;
     }
     // switch
     return parent::setFieldValue($real_name, $set);
 }
 /**
  * Set value of specific field
  *
  * @param string $name
  * @param mided $value
  * @return mixed
  */
 function setFieldValue($name, $value)
 {
     $real_name = $this->realFieldName($name);
     $set = $value;
     switch ($real_name) {
         case 'id':
             $set = intval($value);
             break;
         case 'parent_id':
             $set = intval($value);
             break;
         case 'parent_type':
             $set = strval($value);
             break;
         case 'name':
             $set = strval($value);
             break;
         case 'mime_type':
             $set = strval($value);
             break;
         case 'size':
             $set = intval($value);
             break;
         case 'location':
             $set = strval($value);
             break;
         case 'attachment_type':
             $set = strval($value);
             break;
         case 'created_on':
             $set = datetimeval($value);
             break;
         case 'created_by_id':
             $set = intval($value);
             break;
         case 'created_by_name':
             $set = strval($value);
             break;
         case 'created_by_email':
             $set = strval($value);
             break;
     }
     // switch
     return parent::setFieldValue($real_name, $set);
 }
 /**
  * Set value of specific field
  *
  * @param string $name
  * @param mided $value
  * @return mixed
  */
 function setFieldValue($name, $value)
 {
     $real_name = $this->realFieldName($name);
     $set = $value;
     switch ($real_name) {
         case 'id':
             $set = intval($value);
             break;
         case 'mail_id':
             $set = intval($value);
             break;
         case 'temporary_filename':
             $set = strval($value);
             break;
         case 'original_filename':
             $set = strval($value);
             break;
         case 'content_type':
             $set = strval($value);
             break;
         case 'file_size':
             $set = intval($value);
             break;
     }
     // switch
     return parent::setFieldValue($real_name, $set);
 }
Exemplo n.º 19
0
 /**
  * Set value of specific field
  *
  * @param string $name
  * @param mided $value
  * @return mixed
  */
 function setFieldValue($name, $value)
 {
     $real_name = $this->realFieldName($name);
     $set = $value;
     switch ($real_name) {
         case 'id':
             $set = intval($value);
             break;
         case 'company_id':
             $set = intval($value);
             break;
         case 'role_id':
             $set = intval($value);
             break;
         case 'first_name':
             $set = strval($value);
             break;
         case 'last_name':
             $set = strval($value);
             break;
         case 'email':
             $set = strval($value);
             break;
         case 'password':
             $set = strval($value);
             break;
         case 'token':
             $set = strval($value);
             break;
         case 'created_on':
             $set = datetimeval($value);
             break;
         case 'updated_on':
             $set = datetimeval($value);
             break;
         case 'last_login_on':
             $set = datetimeval($value);
             break;
         case 'last_visit_on':
             $set = datetimeval($value);
             break;
         case 'last_activity_on':
             $set = datetimeval($value);
             break;
         case 'auto_assign':
             $set = boolval($value);
             break;
         case 'auto_assign_role_id':
             $set = intval($value);
             break;
         case 'auto_assign_permissions':
             $set = strval($value);
             break;
         case 'password_reset_key':
             $set = strval($value);
             break;
         case 'password_reset_on':
             $set = datetimeval($value);
             break;
     }
     // switch
     return parent::setFieldValue($real_name, $set);
 }
$varDir = eZSys::varDirectory();
$newStaticDir = StaticData::directory();

$fileUtils = eZClusterFileHandler::instance( $path );
if( $fileUtils->requiresClusterizing() ) {
    $dfsBackend = new eZDFSFileHandlerDFSBackend();
    $mountPoint = $dfsBackend->getMountPoint();
    $varDir = eZDir::path(array($mountPoint, $varDir));
    $newStaticDir = eZDir::path(array($mountPoint, $newStaticDir));
}

$clusterList = ClusterTool::globCluster();
$oldStaticDir = eZDir::path(array($varDir, 'static-data'));

$applicationList = array();
$rows = ApplicationObject::fetchObjectList(ApplicationObject::definition(), array('identifier'), null, null, null, false);
foreach ($rows as $row) {
    $applicationList[] = $row['identifier'];
}
$applicationList = array_unique($applicationList);

$fileToRemove = array();

function moveIfNeeded($oldPath, $newPath) {
    global $fileToRemove;
    
    $success = true;
    $cli = eZCLI::instance();
    
    if (!file_exists($newPath)) {
        if (!file_exists($oldPath)) {
 /**
  * Set value of specific field
  *
  * @param string $name
  * @param mided $value
  * @return mixed
  */
 function setFieldValue($name, $value)
 {
     $real_name = $this->realFieldName($name);
     $set = $value;
     switch ($real_name) {
         case 'id':
             $set = intval($value);
             break;
         case 'company_id':
             $set = intval($value);
             break;
         case 'group_id':
             $set = intval($value);
             break;
         case 'name':
             $set = strval($value);
             break;
         case 'leader_id':
             $set = intval($value);
             break;
         case 'leader_name':
             $set = strval($value);
             break;
         case 'leader_email':
             $set = strval($value);
             break;
         case 'overview':
             $set = strval($value);
             break;
         case 'status':
             $set = strval($value);
             break;
         case 'type':
             $set = strval($value);
             break;
         case 'default_visibility':
             $set = boolval($value);
             break;
         case 'starts_on':
             $set = dateval($value);
             break;
         case 'completed_on':
             $set = datetimeval($value);
             break;
         case 'completed_by_id':
             $set = intval($value);
             break;
         case 'completed_by_name':
             $set = strval($value);
             break;
         case 'completed_by_email':
             $set = strval($value);
             break;
         case 'created_on':
             $set = datetimeval($value);
             break;
         case 'updated_on':
             $set = datetimeval($value);
             break;
         case 'created_by_id':
             $set = intval($value);
             break;
         case 'created_by_name':
             $set = strval($value);
             break;
         case 'created_by_email':
             $set = strval($value);
             break;
         case 'open_tasks_count':
             $set = intval($value);
             break;
         case 'total_tasks_count':
             $set = intval($value);
             break;
     }
     // switch
     return parent::setFieldValue($real_name, $set);
 }
$db = MMDB::instance();

$countryCode = $options['country-code'];
$clusterIdentifier = $options['cluster-identifier'];
$appId = $options['appid'];
$dryRun = (isset( $options["dry-run"] )) ? true : false;

$clusterMapping = eZINI::instance( 'merck.ini' )->variable('ClusterSettings', 'CountryMapping');
if (!array_key_exists($countryCode, $clusterMapping))
{
    $cli->error('No cluster mapping is defined in merck.ini for country-code ' . $countryCode);
    $script->shutdown(1);
}
$clusterIdentifier = $clusterMapping[$countryCode];

$application = ApplicationObject::fetchObject(ApplicationObject::definition(), null, array('id' => $appId));
if ($application == null || $application instanceof ApplicationObject == false)
{
    $cli->error("Application with id {$appId} doesn't exist.");
    $script->shutdown(1);
}
$applicationIdentifier = $application->identifier;

$questionCli = new QuestionInteractiveCli();
$replies = array(
    'N' => 'N',
    'Y' => 'Y'
);
$response = $questionCli->askQuestion( "Are you sure you want to remove application {$application->identifier} for country {$countryCode}", $replies);
if ($response == 'N')
{
    /**
     * @param bool $forAnonmyous
     * @param null $processedUserCustomerType
     * @return int[]
     */
    public static function fetchAuthorizedApplicationIds( $forAnonmyous = false, $processedUserCustomerType = null )
    {
        if( !$forAnonmyous && !is_null(self::$_authorizedApplications) )
            return self::$_authorizedApplications;
        $db = MMDB::instance();

        $customerType   = null;
        $mainSpeciality = null;

        $whereString = sprintf(
            "     cluster_identifier='%s' 
              AND environment & %d",
            $db->escapeString(ClusterTool::clusterIdentifier()),
            ContextTool::instance()->environment()
        );
        
        $user = $forAnonmyous ? false : MMUsers::getCurrentUserObject();

        if( $user )
        {
            /* @var $user MMUsers */
            $user = MMUsers::getCurrentUserObject();

            $customerType   = $user->attribute('customer_type');
            $mainSpeciality = $user->attribute('main_speciality');

            if( $user->hasAttribute('prefered_language'))
            {
                $language = $user->attribute('prefered_language');

                $whereString.= sprintf(
                    " AND ( language = '%s' OR language IS NULL OR language = '0' )",
                    $db->escapeString($language)
                );
            }

            if( $user->hasAttribute('country'))
            {
                $country = $user->attribute('country');

                $whereString.= sprintf(
                    " AND ( country = '%s' OR country IS NULL OR country = '0' )",
                    $db->escapeString($country)
                );
            }
        }

        if (!$customerType && $processedUserCustomerType) {
            $customerType = $processedUserCustomerType;
        }
        $whereString .= is_null($customerType)
            ? ' AND customer_type IS NULL '
            : sprintf( " AND ( customer_type IS NULL OR customer_type = '0' OR customer_type='%s') ", $db->escapeString($customerType) );
        $whereString .= is_null($mainSpeciality)
            ? ' AND main_speciality IS NULL '
            : sprintf( " AND ( main_speciality IS NULL OR main_speciality = '0' OR main_speciality='%s') ", $db->escapeString($mainSpeciality) );

        $sql = "SELECT *
            FROM mm_country_application_library
            WHERE
            ".$whereString."
            ORDER BY country DESC, language DESC, customer_type DESC, main_speciality DESC";

        $lastProfile    = null;
        $excludedApps   = array();
        $applicationIds = array();

        foreach( $db->arrayQuery($sql) as $row )
        {
            $profile = serialize( array($row['customer_type'], $row['main_speciality']) );
            if( !is_null($lastProfile) && $profile != $lastProfile )
                break;

            $lastProfile = $profile;

            if( $user && $user->hasAttribute('state') && !is_null($user->attribute('state')) && $row['state'] === $user->attribute('state') )
            {
                $excludedApps[] = (int)$row['application_id'];
                continue;
            }

            $applicationIds[] = (int) $row['application_id'];
        }

        if( !empty($excludedApps) )
        {
            foreach ( $applicationIds as $k => $appId )
            {
                if( in_array($appId, $excludedApps ) )
                    unset( $applicationIds[$k] );
            }
            $applicationIds = array_values($applicationIds);
        }
        
        if(SolrSafeOperatorHelper::featureIsActive('LearningNeedsAssessment'))
        {
            $applicationIds[] = ApplicationObject::fetchByIdentifier('learning-needs-assessment')->attribute('id');
        }

        $applicationIds = array_unique( $applicationIds );

        if( !$forAnonmyous )
            self::$_authorizedApplications = $applicationIds;

        return $applicationIds;
    }
Exemplo n.º 24
0
 /**
  * Set value of specific field
  *
  * @param string $name
  * @param mided $value
  * @return mixed
  */
 function setFieldValue($name, $value)
 {
     $real_name = $this->realFieldName($name);
     $set = $value;
     switch ($real_name) {
         case 'name':
             $set = strval($value);
             break;
         case 'is_system':
             $set = boolval($value);
             break;
         case 'position':
             $set = intval($value);
             break;
     }
     // switch
     return parent::setFieldValue($real_name, $set);
 }
 /**
  * Set value of specific field
  *
  * @param string $name
  * @param mided $value
  * @return mixed
  */
 function setFieldValue($name, $value)
 {
     $real_name = $this->realFieldName($name);
     $set = $value;
     switch ($real_name) {
         case 'id':
             $set = intval($value);
             break;
         case 'user_id':
             $set = intval($value);
             break;
         case 'object_id':
             $set = intval($value);
             break;
         case 'comment':
             $set = strval($value);
             break;
         case 'created_by_id':
             $set = intval($value);
             break;
         case 'created_by_name':
             $set = strval($value);
             break;
         case 'created_by_email':
             $set = strval($value);
             break;
         case 'created_on':
             $set = datetimeval($value);
             break;
     }
     // switch
     return parent::setFieldValue($real_name, $set);
 }
 /**
  * Find last attachment for a given object
  *
  * @param ApplicationObject $object
  * @return Attachment
  */
 function findLastByObject($object)
 {
     return Attachments::find(array('conditions' => array('parent_id = ? AND parent_type = ?', $object->getId(), get_class($object)), 'order' => 'created_on DESC', 'limit' => 1, 'one' => true));
 }
    /**
     * @param ApplicationLocalized $applicationLocalized
     * @param string $name
     * @param array $params
     * @return mixed|null
     */
    public static function getSeoParam($applicationLocalized, $name, $params)
    {
        if( !($applicationLocalized instanceof ApplicationLocalized) ) {
            /** @var ApplicationObject $application */
            $application = ApplicationObject::fetchByIdentifier($applicationLocalized);
            if(!$application)
            {
                return null;
            }

            $applicationLocalized = $application->applicationLocalized();
        }

        $seo = $applicationLocalized->seoParams();
        if(!$seo || !$seo->hasAttribute($name))
        {
            return null;
        }

        $seoParam = $seo->attribute($name);
        foreach($params as $key => $value)
        {
            $seoParam = str_replace($key, $value, $seoParam);
        }

        return $seoParam;
    }
 /**
  * Set value of specific field
  *
  * @param string $name
  * @param mided $value
  * @return mixed
  */
 function setFieldValue($name, $value)
 {
     $real_name = $this->realFieldName($name);
     $set = $value;
     switch ($real_name) {
         case 'id':
             $set = intval($value);
             break;
         case 'category_id':
             $set = intval($value);
             break;
         case 'type':
             $set = strval($value);
             break;
         case 'name':
             $set = strval($value);
             break;
         case 'body':
             $set = strval($value);
             break;
         case 'mime_type':
             $set = strval($value);
             break;
         case 'visibility':
             $set = intval($value);
             break;
         case 'is_pinned':
             $set = boolval($value);
             break;
         case 'created_by_id':
             $set = intval($value);
             break;
         case 'created_by_name':
             $set = strval($value);
             break;
         case 'created_by_email':
             $set = strval($value);
             break;
         case 'created_on':
             $set = datetimeval($value);
             break;
     }
     // switch
     return parent::setFieldValue($real_name, $set);
 }
 /**
  * Set value of specific field
  *
  * @param string $name
  * @param mided $value
  * @return mixed
  */
 function setFieldValue($name, $value)
 {
     $real_name = $this->realFieldName($name);
     $set = $value;
     switch ($real_name) {
         case 'id':
             $set = intval($value);
             break;
         case 'name':
             $set = strval($value);
             break;
         case 'code':
             $set = strval($value);
             break;
         case 'default_rate':
             $set = floatval($value);
             break;
         case 'is_default':
             $set = boolval($value);
             break;
     }
     // switch
     return parent::setFieldValue($real_name, $set);
 }
 /**
  * Set value of specific field
  *
  * @param string $name
  * @param mided $value
  * @return mixed
  */
 function setFieldValue($name, $value)
 {
     $real_name = $this->realFieldName($name);
     $set = $value;
     switch ($real_name) {
         case 'user_id':
             $set = intval($value);
             break;
         case 'object_id':
             $set = intval($value);
             break;
         case 'is_owner':
             $set = boolval($value);
             break;
     }
     // switch
     return parent::setFieldValue($real_name, $set);
 }