Author: 60044723
Inheritance: extends CI_Controller
示例#1
0
 function beforeDelete($cascade)
 {
     // Remove the extended data to be tidy.
     // First get the type id
     App::Import('Model', 'Type');
     $Type = new Type();
     $Type->recursive = -1;
     $type_record = Set::extract('/Type/id', $Type->find('first', array('fields' => array('Type.id'), 'conditions' => array('Type.alias' => $this->model->data['Node']['type']))));
     $type_id = $type_record[0];
     // Cool, now find all node schemas
     App::Import('Model', 'NodeSchema.NodeSchema');
     $NodeSchema = new NodeSchema();
     $NodeSchema->actsAs = array('Containable');
     $schemas = $NodeSchema->find('all', array('fields' => array('NodeSchema.table_name'), 'contains' => array('Type' => array('conditions' => array('Type.id' => $type_id)))));
     // Now loop through and check for records on those tables to remove
     if (is_array($schemas) && count($schemas) > 0) {
         foreach ($schemas as $schema) {
             $table_name = $schema['NodeSchema']['table_name'];
             $model = new Model(false, $table_name);
             $model->primaryKey = 'node_id';
             // set the primary key to the node_id
             if ($model->delete($this->model->data['Node']['id'], false)) {
                 return true;
             } else {
                 // return false; // There was some sort of error deleting the associated data. Do we even need this? It doesn't redirect, it stops. Have to handle the error.
             }
         }
     }
     return true;
 }
示例#2
0
 function manageTypes()
 {
     // Delete types in bulk
     if ($_POST['action'] == 'delete' && count($_POST['type_check']) > 0) {
         if ($this->delete('type')) {
             $this->showListTypes("Portfolio types successfully deleted");
             return;
         }
     }
     // if (isset($_POST['delete_type']) | isset($_POST['delete_entry'])) { }
     // If an individual type is specified, edit it (and/or validate and process it)
     // Otherwise, just show the full list of types
     if (empty($_GET['type'])) {
         $this->showListTypes();
     } else {
         $typeID = intval($_GET['type']);
         if (isset($_POST['submit_check'])) {
             // If the form was submitted...
             $type = new Type($_POST);
             if ($form_errors = $type->validate()) {
                 $this->editIndividualType($typeID, $form_errors);
             } else {
                 $type->process();
             }
         } else {
             $this->editIndividualType($typeID);
             // If not, just edit the type
         }
     }
 }
 /**
  * Answer the organizer above the reference node that can accept the component type given.
  * 
  * @param object SiteComponent $refNode
  * @param object Type $componentType
  * @return object OrganizerSiteComponent
  * @access public
  * @since 1/15/09
  * @static
  */
 public static function getOrganizerForComponentType(SiteComponent $refNode, Type $componentType)
 {
     // For pages and sections, find the menu above our component.
     if ($componentType->getDomain() == 'segue-multipart') {
         $parentComponent = $refNode->getParentComponent();
         while ($parentComponent) {
             if ($parentComponent->getComponentClass() == 'MenuOrganizer') {
                 return $parentComponent;
             }
             $parentComponent = $parentComponent->getParentComponent();
         }
         // If we didn't find a menu above our ref node, maybe we started in a heading.
         // Search down for a menu.
         $director = SiteDispatcher::getSiteDirector();
         $rootNode = $director->getRootSiteComponent($refNode->getId());
         $result = $rootNode->acceptVisitor(new GetMenuBelowSiteVisitor());
         if ($result) {
             return $result;
         }
         // If we still haven't found a menu, then there isn't one in this site.
         // Nothing more we can do.
         throw new OperationFailedException("Cannot create a " . $componentType->getKeyword() . ". Site " . $rootNode->getSlot()->getShortname() . " - '" . $rootNode->getDisplayName() . "' does not have any menus to add this component to.");
     } else {
         $parentComponent = $refNode->getParentComponent();
         while ($parentComponent) {
             if ($parentComponent->getComponentClass() == 'FlowOrganizer' || $parentComponent->getComponentClass() == 'MenuOrganizer') {
                 return $parentComponent;
             }
         }
         // If we haven't found a flow organizer above the refNode, something is wrong.
         throw new OperationFailedException("Cannot create a " . $componentType->getKeyword() . ". A ContentOrganizer was not found above reference node " . $refNode->getId());
     }
 }
示例#4
0
 /**
  * This method checks if $value confirms to Type, if $value does not confirm to type, throws an exception or returns null if $soft is true
  *
  * @param            $value
  * @param string     $variableName Used in the message of the Exception, to ease debugging
  * @param bool       $soft
  *
  * @return mixed
  */
 public function check($value, $variableName = "unknown", $soft = false)
 {
     if ($value === null) {
         return null;
     }
     return $this->type->check($value, $variableName, $soft);
 }
示例#5
0
 function check($value = null, $schema = null, $path = null, $i = null)
 {
     $type = isset($schema->type) ? $schema->type : null;
     $isValid = true;
     if (is_array($type)) {
         $validatedOneType = false;
         $errors = array();
         foreach ($type as $tp) {
             $validator = new Type($this->checkMode);
             $subSchema = new \stdClass();
             $subSchema->type = $tp;
             $validator->check($value, $subSchema, $path, null);
             $error = $validator->getErrors();
             if (!count($error)) {
                 $validatedOneType = true;
                 break;
             } else {
                 $errors = $error;
             }
         }
         if (!$validatedOneType) {
             return $this->addErrors($errors);
         }
     } elseif (is_object($type)) {
         $this->checkUndefined($value, $type, $path);
     } else {
         $isValid = $this->validateType($value, $type);
     }
     if ($isValid === false) {
         $this->addError($path, gettype($value) . " value found, but a " . $type . " is required");
     }
 }
示例#6
0
 /**
  * Build the content for this action
  * 
  * @return boolean
  * @access public
  * @since 4/26/05
  */
 function buildContent()
 {
     $actionRows = $this->getActionRows();
     $harmoni = Harmoni::instance();
     ob_start();
     CollectionsPrinter::printFunctionLinks();
     print "<p>";
     print _("Below are listed the available <em>Collections</em>, organized by type, then name.");
     print "</p>\n<p>";
     print _("Some <em>Collections</em>, <em>Exhibitions</em>, <em>Assets</em>, and <em>Slide-Shows</em> may be restricted to certain users or groups of users. Log in above to ensure your greatest access to all parts of the system.");
     print "</p>";
     $actionRows->add(new Block(ob_get_contents(), STANDARD_BLOCK), "100%", null, CENTER, CENTER);
     ob_end_clean();
     $exhibitionRepositoryType = new Type('System Repositories', 'edu.middlebury.concerto', 'Exhibitions');
     $repositoryManager = Services::getService("Repository");
     // Get all the types
     $types = $repositoryManager->getRepositoryTypes();
     // put the drs into an array and order them.
     $typeArray = array();
     while ($types->hasNext()) {
         $type = $types->next();
         // include all but Exhibitions repository.
         if (!$exhibitionRepositoryType->isEqual($type)) {
             $typeArray[HarmoniType::typeToString($type)] = $type;
         }
     }
     ksort($typeArray);
     // print the Results
     $resultPrinter = new ArrayResultPrinter($typeArray, 2, 20, "printTypeShort");
     $resultPrinter->addLinksStyleProperty(new MarginTopSP("10px"));
     $resultLayout = $resultPrinter->getLayout();
     $actionRows->add($resultLayout, null, null, CENTER, CENTER);
 }
示例#7
0
 /**
  * Metodo que calcula el porcentaje de los tipos de gasto del usuario pasado
  * como parametro en funcion del rango de fechas pasado como parametro.
  * Para realizar el calculo, primero obtiene todos los gastos y la cantidad
  * numerica de gasto que representan. Despues se invoca a un metodo privado
  * para conocer el total de gasto del usuario y se calculan los porcentajes
  * de cada tipo de gasto. Finalmente, se crea un tipo de gasto especial que
  * representa el porcentaje de gasto de aquellos gastos que no tengan ningun
  * tipo de gasto asignado.
  */
 public function findByOwnerAndFilterWithPercents($owner, $startDate, $endDate)
 {
     $stmt = $this->db->prepare("SELECT SUM(s.quantity) as 'spending.quantity',\n                t.idType as 'type.id',\n                t.name as 'type.name'\n        FROM SPENDING s LEFT JOIN TYPE_SPENDING ts  ON s.idSpending = ts.spending LEFT JOIN TYPE t on ts.type = t.idType\n        WHERE s.owner = ?  AND s.dateSpending BETWEEN ? AND ? AND ts.spending IS NOT NULL GROUP BY ts.type");
     $stmt->execute(array($owner, $startDate, $endDate));
     $types_db = $stmt->fetchAll(PDO::FETCH_ASSOC);
     if (sizeof($types_db)) {
         $total = $this->getTotal($owner, $startDate, $endDate);
         $types = [];
         foreach ($types_db as $type_loop) {
             $type = new Type();
             $type->setName($type_loop['type.name']);
             $percent = $type_loop["spending.quantity"] * 100 / $total;
             array_push($types, array("typename" => $type->getName(), "percent" => round($percent, 2), "total" => (double) $type_loop["spending.quantity"]));
         }
         $totalWithoutType = $this->getTotalSpendingsWithoutType($owner, $startDate, $endDate);
         if ($totalWithoutType != 0) {
             $percentSpecialType = $totalWithoutType * 100 / $total;
             $specialType = new Type();
             $specialType->setName("Without category");
             array_push($types, array("typename" => $specialType->getName(), "percent" => round($percentSpecialType, 2), "total" => (double) $totalWithoutType));
         }
         return $types;
     } else {
         return NULL;
     }
 }
示例#8
0
 public function resolves(Type $a, Type $b)
 {
     if ($a->equals($b)) {
         return true;
     }
     if ($a->type === Type::TYPE_LONG && $b->type === Type::TYPE_DOUBLE) {
         return true;
     }
     if ($a->type === Type::TYPE_USER && $b->type === Type::TYPE_USER) {
         foreach ($b->userTypes as $bt) {
             $bt = strtolower($bt);
             foreach ($a->userTypes as $at) {
                 $at = strtolower($at);
                 if (!isset($this->components['resolves'][$bt][$at])) {
                     continue 2;
                 }
             }
             // We got here, means we found an B type that's resolved by all A types
             return true;
         }
         // That means there is no A type that fully resolves at least one B type
         return false;
     }
     if (($b->type & $a->type) === $a->type) {
         return true;
     }
     return false;
 }
示例#9
0
 public function allows(Type $type) : bool
 {
     if ($type instanceof ComposedType) {
         return !in_array(false, array_map([$this, 'allows'], $type->decoratedTypes()));
     }
     return $type instanceof self;
 }
 public function update(Type $t)
 {
     $q = $this->_db->prepare('UPDATE Types SET libelle= :libelle WHERE id = :id');
     $q->bindValue(':id', $t->getId(), PDO::PARAM_INT);
     $q->bindValue(':libelle', $t->getLibelle(), PDO::PARAM_STR);
     $q->execute();
 }
function getVisitorLoginLink()
{
    $harmoni = Harmoni::instance();
    $authN = Services::getService("AuthN");
    // Visitor Registration Link
    $authTypes = $authN->getAuthenticationTypes();
    $hasVisitorType = false;
    $visitorType = new Type("Authentication", "edu.middlebury.harmoni", "Visitors");
    while ($authTypes->hasNext()) {
        $authType = $authTypes->next();
        if ($visitorType->isEqual($authType)) {
            $hasVisitorType = true;
            break;
        }
    }
    if ($hasVisitorType && !$authN->isUserAuthenticatedWithAnyType()) {
        $harmoni->request->startNamespace('polyphony');
        $url = $harmoni->request->mkURL("auth", "login_type");
        $url->setValue("type", urlencode($visitorType->asString()));
        // Add return info to the visitor registration url
        $visitorReturnModules = array('view', 'ui1', 'ui2', 'versioning');
        if (in_array($harmoni->request->getRequestedModule(), $visitorReturnModules)) {
            $url->setValue('returnModule', $harmoni->request->getRequestedModule());
            $url->setValue('returnAction', $harmoni->request->getRequestedAction());
            $url->setValue('returnKey', 'node');
            $url->setValue('returnValue', SiteDispatcher::getCurrentNodeId());
        }
        $harmoni->request->endNamespace();
        return "\n\t<a href='" . $url->write() . "'>" . _("Visitor Login") . "</a>";
    }
    return null;
}
示例#12
0
 public function __construct(Type &$_typeObject)
 {
     $this->_typeObject = $_typeObject;
     $this->postType = $_typeObject->getPostType();
     $args = $_typeObject->getQueryArgs();
     parent::__construct($args, $this->postType);
 }
示例#13
0
文件: Generator.php 项目: genkgo/push
 /**
  * @param Type $type
  * @param $appId
  * @return PushCertificate
  */
 public function generate(Type $type, $appId)
 {
     $app = $this->portalConnection->fetchApp($appId);
     $privateKey = new PrivateKey();
     $csrCommonName = $app->getName() . ' ' . $type->getHumanReadable() . ' Push Certificate';
     $signingRequest = new SigningRequest($privateKey, $csrCommonName, $this->portalConnection->getAppleId());
     return new PushCertificate($privateKey, $this->portalConnection->signCertificate($signingRequest, $type, $app->getAppIdId()));
 }
示例#14
0
 public function testIsAndToString()
 {
     foreach (array(Type::CHOICE, Type::IDENTIFIER, Type::LOOP, Type::OPTION, Type::RANGE, Type::RULE, Type::SEQUENCE, Type::SYNTAX, Type::TERMINAL) as $typeName) {
         $t = new Type($typeName);
         $this->assertTrue($t->is($typeName));
         $this->assertEquals($typeName, $t->__toString());
     }
 }
示例#15
0
 /**
  * Sets the document type name.
  *
  * @param Type|string $type Type name
  *
  * @return $this
  */
 public function setType($type)
 {
     if ($type instanceof Type) {
         $this->setIndex($type->getIndex());
         $type = $type->getName();
     }
     return $this->setParam('_type', $type);
 }
 /**
  * Returns the values of wizard-components. Should return an array if children are involved,
  * otherwise a whatever type of object is expected.
  * @access public
  * @return mixed
  */
 function getAllValues()
 {
     $type = new Type();
     $type->setDomain($this->_domain->getAllValues());
     $type->setAuthority($this->_authority->getAllValues());
     $type->setKeyword($this->_keyword->getAllValues());
     return $type;
 }
示例#17
0
 /**
  * @param Type $type
  *
  * @return string
  * @throws exceptions\DBDuplicateEntryException
  * @throws exceptions\DBForeignKeyException
  */
 public function store(Type $type)
 {
     $query = 'INSERT INTO types (name, description) VALUES (:name, :description);';
     $this->db->prepare($query);
     $this->db->bindValue(':name', $type->getName());
     $this->db->bindValue(':description', $type->getDescription());
     $this->db->execute();
     return $this->db->lastInsertId();
 }
示例#18
0
文件: Type.php 项目: tueena/core
 /**
  * @param Type $OtherType
  * @return bool
  */
 public function isInstanceOf(Type $OtherType)
 {
     $thisTypeName = $this->getName();
     $otherTypeName = $OtherType->getName();
     if ($thisTypeName === $otherTypeName) {
         return true;
     }
     return (new \ReflectionClass($thisTypeName))->isSubclassOf($otherTypeName);
 }
示例#19
0
 public function allows(Type $type) : bool
 {
     if ($type instanceof self) {
         return true;
     }
     if ($type instanceof ClassType) {
         return $type->reflection()->isInvokable();
     }
     return false;
 }
示例#20
0
 public function combineWith(Type $otherType) : Type
 {
     if ($otherType instanceof $this) {
         return new self($this->isNullable() || $otherType->isNullable());
     }
     if ($otherType instanceof NullType) {
         return $this->makeNullable();
     }
     return new MixedType($this->isNullable() || $otherType->isNullable());
 }
示例#21
0
 /**
  * This method checks if $value confirms to Type, if $value does not confirm to type, throws an exception or returns null if $soft is true
  *
  * @param            $value
  * @param string     $variableName Used in the message of the Exception, to ease debugging
  * @param bool       $soft
  *
  * @return mixed
  */
 public function check($value, $variableName = "unknown", $soft = false)
 {
     if ($value === null && $this->defaultOnNull) {
         return $this->defaultValue;
     }
     $result = $this->type->check($value, $variableName, $this->defaultOnWrongType);
     if ($result instanceof None) {
         return $this->defaultValue;
     }
     return $result;
 }
示例#22
0
 public function save()
 {
     try {
         $model = new Type();
         $this->data->type->entry = 'typ_' . $this->data->type->entry;
         $model->setData($this->data->type);
         $model->save();
         $this->renderPrompt('information', 'OK', "editEntry('{$this->data->type->entry}');");
     } catch (\Exception $e) {
         $this->renderPrompt('error', $e->getMessage());
     }
 }
示例#23
0
 /**
  * Check Authorizations
  * 
  * @return boolean
  * @access public
  * @since 6/4/08
  */
 function isAuthorizedToExecute()
 {
     $authNManager = Services::getService("AuthN");
     $authTypes = $authNManager->getAuthenticationTypes();
     $visitorType = new Type("Authentication", "edu.middlebury.harmoni", "Visitors");
     while ($authTypes->hasNext()) {
         $authType = $authTypes->next();
         if ($visitorType->isEqual($authType)) {
             return true;
         }
     }
     return false;
 }
示例#24
0
 public function accepts(Type $type) : bool
 {
     if ($type instanceof self) {
         return $this->getItemType()->accepts($type->getItemType());
     }
     if ($type instanceof MixedType) {
         return true;
     }
     if ($this->isNullable() && $type instanceof NullType) {
         return true;
     }
     return false;
 }
示例#25
0
 public function equals(Column $column)
 {
     foreach (['name', 'primary', 'sequence', 'null', 'unique', 'default'] as $prop) {
         if ($this->{$prop} !== $column->{$prop}) {
             return false;
         }
     }
     /* If one, the other, or both aren't set, they're only equal if they're exactly equal */
     if (!isset($this->type, $column->type)) {
         return $this->type === $column->type;
     }
     return $this->type->equals($column->type);
 }
示例#26
0
 /**
  * Import muliple files.
  *
  * @param string[] $input
  *
  * @return bool
  */
 public function importFiles($files, $input, $settings, $importable_model_class)
 {
     $count = 0;
     $data = ['settings' => $settings, 'importable-model' => $importable_model_class];
     foreach ($files as $file) {
         //Move file from tmp folder
         $moved_file = $file->move(storage_path() . '/uploads');
         $data['input'] = array_merge($input, ['path' => $moved_file->getRealPath()]);
         //Push new import job to queue stack
         $this->queue->push('Feijs\\ModelImporter\\Queue\\JobHandler', $data);
         $count++;
     }
     return $count;
 }
示例#27
0
function search_type($str)
{
    global $cp;
    $objTypeList = new Type();
    $objTypeList->addWhere("type LIKE '" . $str . "%'");
    $objTypeList->loadList();
    if ($objTypeList->rMore()) {
        while ($objType = $objTypeList->rNext()) {
            $cur =& $cp->add_node('type');
            $cur->set_data($objType->type);
        }
    }
    return;
}
 /**
  * Checks whether the provided type is either an interface that is equal to or extends this interface
  * or is a class that implements this interface.
  *
  * @param Type $type
  * @return boolean
  */
 public function isAssignableFrom(Type $type)
 {
     if ($type->getName() === $this->getName()) {
         return true;
     }
     if ($type instanceof InterfaceType) {
         return $type->isSubtypeOf($this);
     } else {
         if ($type instanceof ClassType) {
             return $type->isImplementorOf($this);
         }
     }
     return false;
 }
示例#29
0
 /**
  * @param \Magento\Catalog\Api\Data\ProductInterface $product
  * @return \Magento\Bundle\Api\Data\OptionInterface[]
  */
 public function getItems(\Magento\Catalog\Api\Data\ProductInterface $product)
 {
     $optionCollection = $this->type->getOptionsCollection($product);
     $optionList = [];
     /** @var \Magento\Bundle\Model\Option $option */
     foreach ($optionCollection as $option) {
         $productLinks = $this->linkList->getItems($product, $option->getOptionId());
         /** @var \Magento\Bundle\Api\Data\OptionInterface $optionDataObject */
         $optionDataObject = $this->optionFactory->create();
         $this->dataObjectHelper->populateWithArray($optionDataObject, $option->getData(), '\\Magento\\Bundle\\Api\\Data\\OptionInterface');
         $optionDataObject->setOptionId($option->getOptionId())->setTitle($option->getTitle() === null ? $option->getDefaultTitle() : $option->getTitle())->setSku($product->getSku())->setProductLinks($productLinks);
         $optionList[] = $optionDataObject;
     }
     return $optionList;
 }
示例#30
0
 /**
  * Checks whether the provided value is an array and all keys and values
  * are assignable to the key and value type of this instance.
  * 
  * @param mixed $value The provided value.
  * @return boolean
  */
 public function isAssignableFromValue($value)
 {
     if (!is_array($value)) {
         return false;
     }
     foreach ($value as $key => $item) {
         if (!$this->itemType->isAssignableFromValue($item)) {
             return false;
         }
         if (!$this->keyType->isAssignableFromValue($key)) {
             return false;
         }
     }
     return true;
 }