<?php

$this->query("\n    CREATE TABLE `message_application` (\n        `message_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n        `author_id` int(11) unsigned NOT NULL,\n        `app_id` int(11) unsigned NOT NULL,\n        `message` text COLLATE utf8_unicode_ci NOT NULL,\n        `created_at` datetime NOT NULL,\n        PRIMARY KEY (`message_id`),\n        KEY `author_id` (`author_id`),\n        KEY `app_id` (`app_id`)\n    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    CREATE TABLE `message_application_file` (\n        `file_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n        `message_id` int(11) unsigned NOT NULL,\n        `file` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\n        PRIMARY KEY (`file_id`),\n        KEY `message_id` (`message_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;\n");
$this->query("\n    ALTER TABLE `message_application`\n        ADD CONSTRAINT `FK_MESSAGE_APPLICATION_APP_ID`\n            FOREIGN KEY (`app_id`) REFERENCES `application` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `message_application_file`\n        ADD CONSTRAINT `FK_MESSAGE_APPLICATION_FILE_MESSAGE_ID`\n            FOREIGN KEY (`message_id`) REFERENCES `message_application` (`message_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$resource = new Acl_Model_Resource();
$resource->find("editor_settings", "code");
if ($resource_id = $resource->getId()) {
    $data = array("parent_id" => $resource_id, "code" => "editor_settings_messages", "label" => "Access the editor messages", "url" => "message/application/*");
    $resource = new Acl_Model_Resource();
    $resource->find("editor_settings_messages", "code");
    $resource->addData($data)->save();
}
<?php

$resource = new Acl_Model_Resource();
$resource->find("features", "code");
if ($resource->getId()) {
    $resource->setCode("feature")->save();
}
<?php

$resource = new Acl_Model_Resource();
$resource->find("features", "code");
if ($resource_id = $resource->getId()) {
    $data = array("parent_id" => $resource_id, "code" => "feature_topic", "label" => "Topics", "url" => "topic/application/*");
    $resource = new Acl_Model_Resource();
    $resource->find("feature_topic", "code");
    $resource->addData($data)->save();
}
$library->setName('Weather')->save();
// Create the icons
$icons = array("/weather/weather1.png", "/weather/weather2.png", "/weather/weather3.png");
$icon_id = null;
foreach ($icons as $icon) {
    $data = array('library_id' => $library->getId(), 'link' => $icon, 'can_be_colorized' => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($data)->save();
    if (is_null($icon_id)) {
        $icon_id = $image->getId();
    }
}
//Categorization
$category = new Application_Model_Option_Category();
$category->find("misc", "code");
$category_id = null;
if ($category->getId()) {
    $category_id = $category->getId();
}
// Create and declare the feature
$data = array('library_id' => $library->getId(), 'icon_id' => $icon_id, 'code' => 'weather', 'name' => 'Weather', 'model' => 'Weather_Model_Weather', 'desktop_uri' => 'weather/application/', 'mobile_uri' => 'weather/mobile_view/', 'only_once' => 0, 'is_ajax' => 1, 'position' => 240, 'category_id' => $category_id);
$option = new Application_Model_Option();
$option->setData($data)->save();
$resource = new Acl_Model_Resource();
$resource->find("feature", "code");
if ($resource_id = $resource->getId()) {
    $data = array("parent_id" => $resource_id, "code" => "weather", "label" => "Access the weather feature", "url" => "weather/application/*");
    $resource = new Acl_Model_Resource();
    $resource->find("weather", "code");
    $resource->addData($data)->save();
}
<?php

$resource = new Acl_Model_Resource();
$resource->find("features", "code");
if ($resource_id = $resource->getId()) {
    $data = array("parent_id" => $resource_id, "code" => "feature_inapp_messages", "label" => "In-App Messages", "url" => "push/application/*");
    $resource = new Acl_Model_Resource();
    $resource->find("feature_inapp_messages", "code");
    $resource->addData($data)->save();
}
$this->query("\n    UPDATE `application_option` SET `model` = 'Push_Model_Message', `name` = 'In-App Messages' WHERE `code` = 'inapp_messages';\n");
 /**
  * update action for widget controller
  * @throws Exception
  */
 public function updateAction()
 {
     try {
         $translate = Zend_Registry::get('Zend_Translate');
         $id = $this->getRequest()->getParam('id', 0);
         $mdlWidget = new System_Model_Widget();
         $widget = $mdlWidget->find($id)->current();
         if (!$widget) {
             throw new Exception($translate->translate("LBL_ROW_NOT_FOUND"));
         }
         $mdlResource = new Acl_Model_Resource();
         $resource = $mdlResource->find($widget->resource_id)->current();
         $widgetFile = APPLICATION_PATH . '/modules/' . $resource->module . '/widgets.xml';
         if (!file_exists($widgetFile)) {
             throw new Exception($translate->translate("SYSTEM_WIDGET_NOT_FOUND"));
         }
         $sxe = new SimpleXMLElement($widgetFile, null, true);
         $element = null;
         foreach ($sxe as $widgetElement) {
             if ($widgetElement['id'] == $widget->widget_id) {
                 $element = $widgetElement;
                 break;
             }
         }
         if (!$element) {
             throw new Exception($translate->translate("SYSTEM_WIDGET_ELEMENT_NOT_FOUND"));
         }
         #$frmWidget = strval($element->form);
         #$frmWidget = new $frmWidget();
         $frmWidget = ucfirst(strtolower(strval($element->module))) . '_Form_Widgets';
         $frmWidget = strtolower(strval($element->module)) == 'menu' ? 'menu_Form_Widgets' : $frmWidget;
         #$frmWidget = new $frmWidget( array('typeForm'=>'test') );
         $frmWidget = new $frmWidget(array('widgetType' => strtolower(strval($element->widget_type))));
         $hookXml = APPLICATION_PATH . '/configs/hooks.xml';
         $sxeHook = new SimpleXMLElement($hookXml, null, true);
         $cbPosition = $frmWidget->getElement("position");
         foreach ($sxeHook as $hook) {
             $cbPosition->addMultiOption($hook, $hook);
         }
         $mdlMenu = new menu_Model_Menu();
         $mdlMI = new menu_Model_Item();
         $menus = $mdlMenu->getMenus();
         $cbMenuItem = $frmWidget->getElement('menuitem');
         foreach ($menus as $menu) {
             $menuItemData = array();
             $mdlMI->getMenuItemsForWidget(null, $menu, null, $menuItemData);
             $cbMIData[$menu->name] = $menuItemData;
             $cbMenuItem->addMultiOptions($cbMIData);
         }
         $frmWidget->setAction($this->_request->getBaseUrl() . "/system/widget/update");
         $frmWidget->populate($widget->toArray());
         $mdlWidgetDetail = new System_Model_Widgetdetail();
         $renderForAll = $mdlWidgetDetail->isRenderForAll($widget);
         if ($renderForAll === false) {
             $rowsSelected = array();
             $menuItems = $widget->findManyToManyRowset('menu_Model_Item', 'System_Model_Widgetdetail', 'Widget');
             foreach ($menuItems as $menuItemSelected) {
                 $rowsSelected[] = $menuItemSelected->id;
             }
             $frmWidget->populate(array('menuitem' => $rowsSelected));
             $frmWidget->getElement('renderfor')->setValue(1);
         } else {
             $frmWidget->getElement('renderfor')->setValue(0);
             $frmWidget->getElement('menuitem')->setAttrib('disabled', true);
         }
         $params = Zend_Json::decode($widget->params);
         $frmWidget->populate($params);
         if ($this->getRequest()->isPost()) {
             if ($frmWidget->isValid($this->getRequest()->getParams())) {
                 $defaultFormFields = array('id', 'wid', 'mod', 'position', 'title', 'published', 'menuitem', 'csrf_token', 'token', 'widget_id', 'showtitle');
                 $widget->title = $frmWidget->getElement('title')->getValue();
                 $widget->published = $frmWidget->getElement('published')->getValue();
                 $widget->position = $frmWidget->getElement('position')->getValue();
                 $widget->showtitle = $frmWidget->getElement('showtitle')->getValue();
                 $frmWidgetValues = $frmWidget->getValues();
                 $params = array();
                 foreach ($frmWidgetValues as $wvk => $wv) {
                     if (!in_array($wvk, $defaultFormFields)) {
                         #$params[] = $wvk.'='.$wv.'';
                         $params[$wvk] = $wv;
                     }
                 }
                 #$params = implode("\n", $params);
                 #$widget->params = $params;
                 $widget->params = Zend_Json::encode($params);
                 #Zend_Debug::dump( $widget );
                 #die();
                 $widget->save();
                 $menuItemsWidget = $widget->findDependentRowset('System_Model_Widgetdetail', 'Widget');
                 foreach ($menuItemsWidget as $miw) {
                     $miw->delete();
                 }
                 if ($frmWidget->getElement('renderfor')->getValue() == 0) {
                     $widgetDetail = $mdlWidgetDetail->createRow();
                     $widgetDetail->widget_id = $widget->id;
                     $widgetDetail->menuitem_id = null;
                     $widgetDetail->save();
                 } else {
                     foreach ($frmWidget->getValue('menuitem') as $mi) {
                         $widgetDetail = $mdlWidgetDetail->createRow();
                         $widgetDetail->widget_id = $widget->id;
                         $widgetDetail->menuitem_id = $mi;
                         $widgetDetail->save();
                         #Zend_Debug::dump($widgetDetail);
                     }
                 }
                 #Zend_Debug::dump( $menuItemsWidget );
                 $this->_helper->flashMessenger->addMessage(array('type' => 'info', 'header' => '', 'message' => $translate->translate("SYSTEM_WIDGET_UPDATED_SUCCESSFULLY")));
                 $this->_helper->redirector("list", "widget", "system");
             }
         } else {
             /*$fields = array();
             		foreach ( $frmWidget->getElements() as $wfelement ) $fields[] = $wfelement->getName();
             		$frmWidget->addDisplayGroup( $fields, 'form', array( 'legend' => $translate->translate("SYSTEM_UPDATE_WIDGET"), ) );*/
         }
         $this->view->frmWidget = $frmWidget;
         $this->view->widget = $element;
         #Zend_Debug::dump($element);
     } catch (Exception $e) {
         $this->_helper->flashMessenger->addMessage(array('type' => 'error', 'header' => '', 'message' => $e->getMessage()));
         $this->_helper->redirector("list", "widget", "system");
     }
     return;
 }
示例#7
0
 /**
  * Update action for item controller
  * @throws Exception
  * @return NULL
  */
 public function updateAction()
 {
     try {
         $translate = Zend_Registry::get('Zend_Translate');
         $id = $this->getRequest()->getParam('id', 0);
         $mdlMenuItem = new menu_Model_Item();
         $menuItem = $mdlMenuItem->find($id)->current();
         if (!$menuItem) {
             throw new Exception($translate->translate("LBL_ROW_NOT_FOUND"));
         }
         $mdlResource = new Acl_Model_Resource();
         $resource = $mdlResource->find($menuItem->resource_id)->current();
         $menuFile = APPLICATION_PATH . '/modules/' . $resource->module . '/menus.xml';
         if (!file_exists($menuFile)) {
             throw new Exception($translate->translate("MENU_XML_FILE_NOT_FOUND"));
         }
         $sxe = new SimpleXMLElement($menuFile, null, true);
         $element = null;
         foreach ($sxe as $sxeMenuItem) {
             if ($sxeMenuItem['id'] == $menuItem->mid) {
                 $element = $sxeMenuItem;
                 break;
             }
         }
         if (!$element) {
             throw new Exception($translate->translate("MENU_XML_ITEM_ELEMENT_NOT_FOUND"));
         }
         $frmMenuItem = ucfirst(strtolower(strval($element->module))) . '_Form_Menuitems';
         $frmMenuItem = strtolower(strval($element->module)) == 'menu' ? 'menu_Form_Menuitems' : $frmMenuItem;
         $frmMenuItem = new $frmMenuItem(array('menuType' => strtolower(strval($element->menu_type))));
         $mdlMenu = new menu_Model_Menu();
         $menu = $mdlMenu->find($menuItem->menu_id)->current();
         if (!$menu) {
             throw new Exception($translate->translate("MENU_NOT_FOUND"));
         }
         $this->view->menu = $menu;
         $cbParentItem = $frmMenuItem->getElement('parent_id');
         $mdlMenuItem = new menu_Model_Item();
         $menuItemList = $mdlMenuItem->getListItemsByMenu($menu);
         $cbParentItem->addMultiOption(0, $translate->translate("MENU_NOT_PARENT"));
         foreach ($menuItemList as $menuItemRow) {
             $cbParentItem->addMultiOption($menuItemRow->id, $menuItemRow->title);
         }
         if ($this->getRequest()->isPost()) {
             if ($frmMenuItem->isValid($_POST)) {
                 $menuItem->setFromArray($frmMenuItem->getValues());
                 $frmMIValues = $frmMenuItem->getValues();
                 $params = array();
                 foreach ($frmMIValues as $wvk => $wv) {
                     if (!in_array($wvk, $frmMenuItem->defaultFormFields)) {
                         #$params[] = $wvk.'='.$wv.'';
                         $params[$wvk] = $wv;
                     }
                 }
                 #$params = implode("\n", $params);
                 #$menuItem->params = $params;
                 $menuItem->params = Zend_Json::encode($params);
                 #Zend_Debug::dump($menuItem->params);
                 #die();
                 $parentItem = $mdlMenuItem->find($menuItem->parent_id)->current();
                 $menuItem->depth = $parentItem ? $parentItem->depth + 1 : 1;
                 $menuItem->parent_id = $parentItem ? $parentItem->id : null;
                 $menuItem->save();
                 $this->_helper->flashMessenger->addMessage(array('type' => 'info', 'header' => '', 'message' => $translate->translate("MENU_ITEM_UPDATED_SUCCESSFULLY")));
                 $this->redirect('menu-items/' . $menu->id);
             } else {
                 #Zend_Debug::dump($frmMenuItem);
             }
         } else {
             $data = $menuItem->toArray();
             if (strlen($data['id_alias']) == 0) {
                 unset($data['id_alias']);
             }
             $frmMenuItem->populate($data);
             if (strlen($menuItem->params) > 0) {
                 $params = Zend_Json::decode($menuItem->params);
                 $frmMenuItem->populate($params);
             }
             #Zend_Debug::dump($params[0]);
             $frmMenuItem->populate(array('mod' => $resource->module));
             /*$fields = array();
               foreach ( $frmMenuItem->getElements() as $element ) $fields[] = $element->getName();
               $frmMenuItem->addDisplayGroup( $fields, 'form', array( 'legend' => $translate->translate("MENU_UPDATE_MENUITEM"), ) );*/
         }
         $frmMenuItem->setAction($this->_request->getBaseUrl() . "/menu-item-update/" . $menuItem->id);
         $this->view->frmMenuItem = $frmMenuItem;
     } catch (Exception $e) {
         $this->_helper->flashMessenger->addMessage(array('type' => 'error', 'header' => '', 'message' => $e->getMessage()));
         $this->redirect('menu-items/' . $menu->id);
     }
     return;
 }
$library->setName('Tip')->save();
// Create the icons
$icons = array("/tip/tip1.png", "/tip/tip2.png");
$icon_id = null;
foreach ($icons as $icon) {
    $data = array('library_id' => $library->getId(), 'link' => $icon, 'can_be_colorized' => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($data)->save();
    if (is_null($icon_id)) {
        $icon_id = $image->getId();
    }
}
//Categorization
$category = new Application_Model_Option_Category();
$category->find("misc", "code");
$category_id = null;
if ($category->getId()) {
    $category_id = $category->getId();
}
// Create and declare the feature
$data = array('library_id' => $library->getId(), 'icon_id' => $icon_id, 'code' => 'tip', 'name' => 'Tips calculator', 'model' => 'Tip_Model_Tip', 'desktop_uri' => 'tip/application/', 'mobile_uri' => 'tip/mobile_view/', 'only_once' => 0, 'is_ajax' => 1, 'position' => 240, 'social_sharing_is_available' => 0, 'category_id' => $category_id);
$option = new Application_Model_Option();
$option->setData($data)->save();
$resource = new Acl_Model_Resource();
$resource->find("feature", "code");
if ($resource_id = $resource->getId()) {
    $data = array("parent_id" => $resource_id, "code" => "feature_tip", "label" => "Tips calculator", "url" => "tips/application/*");
    $resource = new Acl_Model_Resource();
    $resource->find("feature_tip", "code");
    $resource->addData($data)->save();
}
 /**
  * Delete action for resource controller
  * @throws Zend_Exception
  */
 public function deleteAction()
 {
     $translate = Zend_Registry::get('Zend_Translate');
     try {
         $id = $this->getRequest()->getParam("id");
         $mdlResource = new Acl_Model_Resource();
         $resource = $mdlResource->find($id)->current();
         if (!$resource) {
             throw new Zend_Exception($translate->translate("LBL_ROW_NOT_FOUND"));
         }
         $resource->delete();
         $this->_helper->flashMessenger->addMessage(array('type' => 'info', 'header' => '', 'message' => $translate->translate("LBL_CHANGES_SAVED")));
         $this->_helper->redirector("list", "resource", "acl");
     } catch (Exception $e) {
         $this->_helper->flashMessenger->addMessage(array('type' => 'error', 'header' => '', 'message' => $e->getMessage()));
         $this->_helper->redirector("list", "resource", "acl");
     }
     return;
 }
示例#10
0
<?php

$resource = new Acl_Model_Resource();
$resource->find("features", "code");
if ($resource_id = $resource->getId()) {
    $data = array("parent_id" => $resource_id, "code" => "feature_code_scan", "label" => "Code Scan", "url" => "codescan/application/*");
    $resource = new Acl_Model_Resource();
    $resource->find("feature_code_scan", "code");
    $resource->addData($data)->save();
}
示例#11
0
<?php

$editor_resource = new Acl_Model_Resource();
$editor_resource->find("editor", "code");
$resource_data = array(array("code" => "editor_settings", "label" => "Access the settings from the editor", "children" => array(array("code" => "editor_settings_tc", "label" => "Access the Terms & Conditions tab", "url" => "application/settings_tc/*"), array("code" => "editor_settings_facebook", "label" => "Access the Facebook tab", "url" => "application/settings_facebook/*"), array("code" => "editor_settings_domain", "label" => "Access the Domain tab", "url" => "application/settings_domain/*"))));
foreach ($resource_data as $data) {
    $data["parent_id"] = $editor_resource->getId();
    $resource = new Acl_Model_Resource();
    $resource->setData($data)->save();
    if (!empty($data["children"])) {
        foreach ($data["children"] as $child_resource) {
            $child = new Acl_Model_Resource();
            $child->setData($child_resource)->setParentId($resource->getId())->save();
        }
    }
}
示例#12
0
<?php

$resources = array(array("code" => "feature_magento", "label" => "Magento", "url" => "weblink/application_magento/*"), array("code" => "feature_woocommerce", "label" => "WooCommerce", "url" => "weblink/application_woocommerce/*"), array("code" => "feature_prestashop", "label" => "Prestashop", "url" => "weblink/application_prestashop/*"), array("code" => "feature_volusion", "label" => "Volusion", "url" => "weblink/application_volusion/*"), array("code" => "feature_shopify", "label" => "Shopify", "url" => "weblink/application_shopify/*"));
$resource = new Acl_Model_Resource();
$resource->find("feature", "code");
if ($resource_id = $resource->getId()) {
    foreach ($resources as $data) {
        $resource = new Acl_Model_Resource();
        $resource->find($data["code"], "code");
        if (!$resource->getId()) {
            $data["parent_id"] = $resource_id;
            $resource->addData($data)->save();
        }
    }
}
示例#13
0
<?php

$resource = new Acl_Model_Resource();
$resource->find("features", "code");
if ($resource_id = $resource->getId()) {
    $data = array("parent_id" => $resource_id, "code" => "feature_qr_discount", "label" => "QR Coupons", "url" => "promotion/application/*");
    $resource = new Acl_Model_Resource();
    $resource->find("feature_qr_discount", "code");
    $resource->addData($data)->save();
}
示例#14
0
<?php

$features = array('Magento' => array('icon_path' => '/magento/magento1.png', 'datas' => array('code' => 'magento', 'name' => 'Magento', 'model' => 'Weblink_Model_Type_Mono', 'desktop_uri' => 'weblink/application_magento/', 'mobile_uri' => 'weblink/mobile_mono/', 'only_once' => 0, 'is_ajax' => 0, 'position' => 155)), 'WooCommerce' => array('icon_path' => '/woocommerce/woocommerce1.png', 'datas' => array('code' => 'woocommerce', 'name' => 'WooCommerce', 'model' => 'Weblink_Model_Type_Mono', 'desktop_uri' => 'weblink/application_woocommerce/', 'mobile_uri' => 'weblink/mobile_mono/', 'only_once' => 0, 'is_ajax' => 0, 'position' => 155)), 'Prestashop' => array('icon_path' => '/prestashop/prestashop1.png', 'datas' => array('code' => 'prestashop', 'name' => 'Prestashop', 'model' => 'Weblink_Model_Type_Mono', 'desktop_uri' => 'weblink/application_prestashop/', 'mobile_uri' => 'weblink/mobile_mono/', 'only_once' => 0, 'is_ajax' => 0, 'position' => 155)), 'Volusion' => array('icon_path' => '/volusion/volusion1.png', 'datas' => array('code' => 'volusion', 'name' => 'Volusion', 'model' => 'Weblink_Model_Type_Mono', 'desktop_uri' => 'weblink/application_volusion/', 'mobile_uri' => 'weblink/mobile_mono/', 'only_once' => 0, 'is_ajax' => 0, 'position' => 155)), 'Shopify' => array('icon_path' => '/shopify/shopify1.png', 'datas' => array('code' => 'shopify', 'name' => 'Shopify', 'model' => 'Weblink_Model_Type_Mono', 'desktop_uri' => 'weblink/application_shopify/', 'mobile_uri' => 'weblink/mobile_mono/', 'only_once' => 0, 'is_ajax' => 0, 'position' => 155)));
$resource = new Acl_Model_Resource();
$resource->find("feature", "code");
$resource_id = $resource->getId();
foreach ($features as $feature_name => $feature) {
    $library = new Media_Model_Library();
    $library->setName($feature_name)->save();
    $datas = array('library_id' => $library->getId(), 'link' => $feature['icon_path'], 'can_be_colorized' => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($datas)->save();
    $icon_id = $image->getId();
    $datas = $feature['datas'];
    $datas['library_id'] = $library->getId();
    $datas['icon_id'] = $icon_id;
    $option = new Application_Model_Option();
    $option->setData($datas)->save();
    if ($resource_id) {
        $data = array("parent_id" => $resource_id, "code" => "feature_" . $feature['datas']['code'], "label" => $feature_name, "url" => $feature['datas']['desktop_uri']);
        $resource = new Acl_Model_Resource();
        $resource->find("feature_" . $feature['datas']['code'], "code");
        $resource->addData($data)->save();
    }
}