Exemple #1
0
 public function helpAction()
 {
     $uri = $this->getRequest()->getParam('uri');
     $ns = new Zend_Session_Namespace();
     if (!empty($uri)) {
         $uri = Shineisp_Commons_UrlRewrites::format($uri);
         $data = $this->wiki->getPostbyUri($uri, "w.wiki_id, w.subject as subject, w.views as views, w.creationdate as creationdate, w.content as content, w.metakeywords as metakeywords, w.metadescription as metadescription, wc.category_id as category_id, wc.category as category");
         if (isset($data[0])) {
             // Set the Metatag information
             $this->view->headTitle(" | " . $data[0]['subject']);
             if (!empty($data[0]['metakeywords'])) {
                 $this->view->headMeta()->setName('keywords', $data[0]['metakeywords']);
             }
             if (!empty($data[0]['metadescription'])) {
                 $this->view->headMeta()->setName('description', $data[0]['metadescription']);
             }
             // Getting the Products
             $products = Wikilinks::getProductsAttached($data[0]['wiki_id'], $ns->langid);
             if (count($products) > 0) {
                 $this->view->placeholder("right")->append($this->view->partial('wiki/products_reference.phtml', array('products' => $products)));
                 $this->getHelper('layout')->setLayout('2columns-right');
             }
             // Update the counter
             Wiki::update_views($data[0]['wiki_id']);
             $data[0]['content'] = Shineisp_Commons_Contents::chkModule($data[0]['content']);
             $data[0]['content'] = Shineisp_Commons_Contents::chkCmsBlocks($data[0]['content'], $ns->lang);
             // Send the content to the page
             $this->view->headertitle = $this->translator->translate('Wiki page');
             $this->view->post = $data[0];
         }
     }
 }
Exemple #2
0
 /**
  * Save the permission
  * @param $id
  */
 public static function SaveAll($data, $id = null)
 {
     if (!empty($data) && is_array($data)) {
         if (is_numeric($id)) {
             $role = Doctrine::getTable('AdminRoles')->find($id);
         } else {
             $role = new AdminRoles();
         }
         // Save the role label
         if (!empty($data['name'])) {
             $role['name'] = Shineisp_Commons_UrlRewrites::format($data['name']);
             $role->save();
         }
         // Set the new Role ID to the users selected
         if (!empty($data['users'])) {
             foreach ($data['users'] as $user) {
                 AdminUser::setUserRoleID($user, $id);
             }
         }
         // Clear old permissions
         AdminPermissions::clearPermissionByRoleID($id);
         if (!empty($data['resources'])) {
             // Explode the string into an array
             $resources = explode("/", $data['resources']);
             // Add the new permissions
             foreach ($resources as $resource) {
                 list($module, $controller) = explode(':', $resource);
                 AdminPermissions::addPermission($id, $module, $controller);
             }
         }
         return $role;
     }
     return false;
 }
 /**
  * processAction
  * Update the record previously selected
  * @return unknown_type
  */
 public function processAction()
 {
     $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
     $form = $this->getForm("/admin/productsattributesgroups/process");
     $request = $this->getRequest();
     // Create the buttons in the edit form
     $this->view->buttons = array(array("url" => "#", "label" => $this->translator->translate('Save'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/productsattributesgroups/list", "label" => $this->translator->translate('List'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/productsattributesgroups/new/", "label" => $this->translator->translate('New'), "params" => array('css' => null)));
     try {
         // Check if we have a POST request
         if (!$request->isPost()) {
             return $this->_helper->redirector('list', 'productsattributesgroups', 'admin');
         }
         if ($form->isValid($request->getPost())) {
             // Get the id
             $id = $this->getRequest()->getParam('group_id');
             // Set the new values
             if (is_numeric($id)) {
                 $this->productsattributesgroups = $this->productsattributesgroups->find($id);
             }
             // Get the values posted
             $params = $form->getValues();
             $this->productsattributesgroups->name = $params['name'];
             $this->productsattributesgroups->code = Shineisp_Commons_UrlRewrites::format($params['name']);
             $this->productsattributesgroups->isrecurring = $params['isrecurring'] ? 1 : 0;
             $this->productsattributesgroups->iscomparable = $params['iscomparable'] ? 1 : 0;
             $this->productsattributesgroups->isp_id = Shineisp_Registry::get('ISP')->isp_id;
             $this->productsattributesgroups->save();
             $id = is_numeric($id) ? $id : $this->productsattributesgroups->getIncremented();
             // Delete the old group
             ProductsAttributesGroupsIndexes::deleteAllAttributes($id);
             if (!empty($params['attributes'])) {
                 ProductsAttributesGroupsIndexes::AddAttributes($id, $params['attributes']);
             }
             $this->_helper->redirector('edit', 'productsattributesgroups', 'admin', array('id' => $id, 'mex' => $this->translator->translate('The task requested has been executed successfully.'), 'status' => 'success'));
         } else {
             $this->view->form = $form;
             $this->view->title = $this->translator->translate("Hosting Plan Feature details");
             $this->view->description = $this->translator->translate("Here you can fix the hosting plan feature details.");
             return $this->render('applicantform');
         }
     } catch (Exception $e) {
         $this->_helper->redirector('edit', 'productsattributesgroups', 'admin', array('id' => $id, 'mex' => $e->getMessage(), 'status' => 'danger'));
     }
 }
 /**
  * Add a group attribute
  * 
  * @param string $name
  * @param boolean $is_recurring
  * @param boolean $is_comparable
  */
 public static function addNew($id = NULL, $name, $is_recurring = 0, $is_comparable = 0)
 {
     if (is_numeric($id)) {
         $group = self::find($id);
     } else {
         $group = new ProductsAttributesGroups();
     }
     $group['name'] = $name;
     $group['code'] = Shineisp_Commons_UrlRewrites::format($name);
     $group['isrecurring'] = $is_recurring;
     $group['iscomparable'] = $is_comparable;
     $group->save();
     return $group['group_id'];
 }
Exemple #5
0
 /**
  * Save all the data
  * 
  * 
  * @param unknown_type $data
  * @param unknown_type $locale
  */
 public static function saveAll($id, $params, $locale = 1)
 {
     $products = new Products();
     // Set the new values
     if (is_numeric($id)) {
         $products = self::find($id, null, false, $locale);
         if ($products[0]) {
             $products = $products[0];
         }
     } else {
         $products->inserted_at = date('Y-m-d H:i:s');
     }
     // Product UUID is missing, generate a new one
     if (empty($products->uuid)) {
         $products->uuid = Shineisp_Commons_Uuid::generate();
     }
     try {
         if (!empty($_FILES['attachments'])) {
             $file = $_FILES['attachments'];
             if (!empty($file)) {
                 if (!is_dir(PUBLIC_PATH . "/media/products/")) {
                     @mkdir(PUBLIC_PATH . "/media");
                     @mkdir(PUBLIC_PATH . "/media/products");
                 }
             }
         }
         if (is_array($params)) {
             $products->updated_at = date('Y-m-d H:i:s');
             $products->categories = !empty($params['categories']) ? $params['categories'] : null;
             $products->uri = !empty($params['uri']) ? Shineisp_Commons_UrlRewrites::format($params['uri']) : Shineisp_Commons_UrlRewrites::format($params['name']);
             $products->sku = !empty($params['sku']) ? $params['sku'] : '';
             $products->cost = $params['cost'];
             $products->price_1 = !empty($params['price_1']) ? $params['price_1'] : NULL;
             $products->setupfee = !empty($params['setupfee']) ? $params['setupfee'] : NULL;
             $products->enabled = !empty($params['enabled']) ? 1 : 0;
             $products->iscomparable = !empty($params['iscomparable']) ? 1 : 0;
             $products->tax_id = !empty($params['tax_id']) ? $params['tax_id'] : NULL;
             $products->type = !empty($params['type']) ? $params['type'] : "generic";
             $products->blocks = !empty($params['blocks']) ? $params['blocks'] : NULL;
             $products->group_id = !empty($params['group_id']) ? $params['group_id'] : NULL;
             $products->position = !empty($params['position']) ? $params['position'] : NULL;
             $products->setup = !empty($params['setup']) ? $params['setup'] : NULL;
             $products->ishighlighted = !empty($params['ishighlighted']) ? 1 : 0;
             $products->isrefundable = !empty($params['isrefundable']) ? 1 : 0;
             $products->showonrss = !empty($params['showonrss']) ? 1 : 0;
             $products->external_id = !empty($params['external_id']) ? $params['external_id'] : NULL;
             $products->downgradable = !empty($params['downgradable']) ? 1 : 0;
             $products->server_group_id = !empty($params['server_group_id']) ? intval($params['server_group_id']) : null;
             $products->autosetup = !empty($params['autosetup']) ? intval($params['autosetup']) : 0;
             $products->isp_id = Shineisp_Registry::get('ISP')->isp_id;
             // If 0 or NULL, se to NULL. Avoid constraint errors
             $products->welcome_mail_id = !empty($params['welcome_mail_id']) && intval($params['welcome_mail_id']) > 0 ? intval($params['welcome_mail_id']) : null;
             // Save the data
             $products->save();
             $product_id = $products->product_id;
             // Save the product attributes
             ProductsAttributesIndexes::saveAll($params, $product_id);
             $Pdata = ProductsData::findbyProductID($product_id, $locale);
             if (empty($Pdata)) {
                 $Pdata = new ProductsData();
             }
             // TODO: Guestisp: this criteria is not complete. I cannot translate a product already sold in another language
             // a solution is write the name of the product sold in the order as flat data
             //* Product name can not be changed if product is sold
             // 				if ( ! (bool)OrdersItems::CheckIfProductExist($product_id) ) {
             // 					$Pdata->name = $params ['name'];
             // 				}
             $Pdata->name = $params['name'];
             $Pdata->nickname = $params['nickname'];
             $Pdata->shortdescription = $params['shortdescription'];
             $Pdata->description = $params['description'];
             $Pdata->metakeywords = $params['metakeywords'];
             $Pdata->metadescription = $params['metadescription'];
             $Pdata->product_id = $product_id;
             $Pdata->language_id = $locale;
             $Pdata->save();
             // Create the price tranches
             if (!empty($params['tranche_qty']) && !empty($params['tranche_measure']) && !empty($params['tranche_price'])) {
                 $params['tranche_setupfee'] = isset($params['tranche_setupfee']) ? $params['tranche_setupfee'] : 0;
                 $tranches = ProductsTranches::saveAll($product_id, $params['tranche_billing_cycle_id'], $params['tranche_qty'], $params['tranche_measure'], $params['tranche_price'], $params['tranche_setupfee']);
                 $trancheid = $tranches['tranche_id'];
                 if (!empty($params['tranche_includes_domains'])) {
                     foreach ($params['tranche_includes_domains'] as $includeid) {
                         ProductsTranchesIncludes::saveAll($trancheid, $includeid, 'domains');
                     }
                 }
             }
             // Attach the wiki pages to a product
             if (!empty($params['wikipages'])) {
                 Wikilinks::addWikiPages2Products($product_id, $params['wikipages']);
             }
             // Add the related products
             if (!empty($params['related'])) {
                 self::AddRelatedProducts($product_id, $params['related']);
             }
             // Add the upgrade products
             if (!empty($params['upgrade'])) {
                 self::AddUpgradeProducts($product_id, $params['upgrade']);
             }
             // Before to get the Values of the form I upload the files in the folders
             if (!empty($file)) {
                 if ($_FILES['attachments']['error'] == 0) {
                     // Uploading the file
                     $filename = mt_rand(10, 999) . '_' . $_FILES['attachments']['name'];
                     $retval = move_uploaded_file($_FILES['attachments']['tmp_name'], PUBLIC_PATH . "/media/products/" . $filename);
                     if ($retval) {
                         $media = new ProductsMedia();
                         $media->filename = $filename;
                         $media->path = "/media/products/{$filename}";
                         $media->product_id = $product_id;
                         $media->description = $params['filedescription'];
                         $media->enabled = 1;
                         $media->save();
                     }
                 }
             }
             return $product_id;
         } else {
             throw new Exception('Parameters data are not correct.');
         }
     } catch (Exception $e) {
         echo $e->getMessage();
         die;
         return false;
     }
 }
Exemple #6
0
 /**
  * 
  * Save the Cms page data
  */
 public static function saveAll($id, $params, $locale = 1)
 {
     $i = 0;
     // Set the new values
     if (is_numeric($id)) {
         $cmspages = Doctrine::getTable('Cmspages')->find($id);
     } else {
         $cmspages = new CmsPages();
         $cmspages->publishedat = date('Y-m-d H:i:s');
     }
     $cmspages->title = $params['title'];
     $cmspages->body = $params['body'];
     $cmspages->keywords = $params['keywords'];
     $cmspages->blocks = $params['blocks'];
     $cmspages->layout = $params['layout'];
     $cmspages->xmllayout = $params['xmllayout'];
     $cmspages->var = !empty($params['var']) ? Shineisp_Commons_UrlRewrites::format($params['var']) : Shineisp_Commons_UrlRewrites::format($params['title']);
     $cmspages->pagelayout = $params['pagelayout'];
     $cmspages->parent_id = $params['parent_id'];
     $cmspages->showinmenu = $params['showinmenu'] ? true : false;
     $cmspages->showonrss = $params['showonrss'] ? true : false;
     $cmspages->blog = $params['blog'] ? true : false;
     $cmspages->showonrss = $params['showonrss'] ? true : false;
     $cmspages->active = $params['active'] ? true : false;
     if ($cmspages->trySave()) {
         if (is_numeric($cmspages['page_id'])) {
             // Clear old reference records by page_id
             CmsPagesData::deleteItems($cmspages['page_id']);
             // Save the page translation references
             $PageData = new Doctrine_Collection('CmsPagesData');
             foreach ($params['language_id'] as $idlang) {
                 $PageData[$i]->page_id = $cmspages['page_id'];
                 $PageData[$i]->language_id = $idlang;
                 $i++;
             }
             $PageData->save();
         }
     }
     $id = is_numeric($id) ? $id : $cmspages->getIncremented();
     return $id;
 }
Exemple #7
0
 /**
  *  Check the domain availability
  *  @return template
  */
 public function bulkdomainsAction()
 {
     $request = $this->getRequest();
     $session = new Zend_Session_Namespace('Default');
     $i = 0;
     try {
         $form = new Default_Form_BulkdomainsForm(array('action' => '/common/bulkdomains', 'method' => 'post'));
         if ($request->getPost()) {
             if ($form->isValid($request->getPost())) {
                 $params = $form->getValues();
                 if (!empty($params['domains'])) {
                     $checker = new Shineisp_Commons_DomainChecker();
                     $tlds = $request->getParam('tlds');
                     // Clear the temporary domains of the customer
                     if ($session->customer) {
                         $customerId = $session->customer['customer_id'];
                         DomainsBulk::findbyCustomerID($customerId)->delete();
                     } else {
                         $customerId = null;
                     }
                     $domains = explode("\n", $params['domains']);
                     foreach ($domains as $domain) {
                         foreach ($tlds as $tld) {
                             $tldinfo = DomainsTlds::getAllInfo($tld);
                             $domain = Shineisp_Commons_UrlRewrites::format($domain);
                             $domainame = $domain . "." . $tldinfo['DomainsTldsData'][0]['name'];
                             $isAvailable = $checker->checkDomainAvailability($domainame);
                             DomainsBulk::add_domain($domainame, $tld, $isAvailable, $customerId);
                         }
                     }
                     $this->_helper->redirector('bulkdomainsorder', 'common', 'default');
                 }
             }
         }
     } catch (Exception $e) {
         $this->_helper->redirector('index', 'index', 'default', array('mex' => $e->getMessage(), 'status' => 'danger'));
     }
     $this->view->form = $form;
     $this->getHelper('layout')->setLayout('1column');
 }
 /**
  * Add a new Categories
  * 
  * @param string $name
  * @param string $uri
  * @param integer $parent
  * @param integer $enabled
  * @param integer $position
  * @param string $description
  * @param string $keywords
  * @param integer $externalid
  * @param array $custom
  * @param string $blocks
  */
 public static function addNew($name, $uri, $parent = 0, $enabled = 1, $position = null, $description = "", $keywords = "", $externalid = null, $custom = null, $blocks = "")
 {
     $cat = new ProductsCategories();
     $cat->name = $name;
     $cat->parent = $parent;
     $cat->enabled = $enabled;
     $cat->description = $description;
     $cat->keywords = $keywords;
     $cat->uri = Shineisp_Commons_UrlRewrites::format($uri);
     $cat->blocks = $blocks;
     $cat->position = $position;
     $cat->externalid = $externalid;
     $cat->custom = $custom;
     if ($cat->trySave()) {
         return $cat['category_id'];
     }
 }
Exemple #9
0
 /**
  * 
  * Save the Cms Block data
  */
 public static function saveAll($id, $params, $locale = 1)
 {
     $i = 0;
     // Set the new values
     if (is_numeric($id)) {
         $cmsblock = Doctrine::getTable('CmsBlocks')->find($id);
     } else {
         $cmsblock = new CmsBlocks();
         $cmsblock->publishedat = date('Y-m-d H:i:s');
     }
     $cmsblock->title = $params['title'];
     $cmsblock->body = $params['body'];
     $cmsblock->var = Shineisp_Commons_UrlRewrites::format($params['var']);
     if ($cmsblock->trySave()) {
         if (is_numeric($cmsblock['block_id'])) {
             // Clear old reference records by page_id
             CmsBlocksData::deleteItems($cmsblock['block_id']);
             // Save the page translation references
             $PageData = new Doctrine_Collection('CmsBlocksData');
             foreach ($params['language_id'] as $idlang) {
                 $PageData[$i]->block_id = $cmsblock['block_id'];
                 $PageData[$i]->language_id = $idlang;
                 $i++;
             }
             $PageData->save();
         }
     }
 }
 /**
  *  Check the domain availability
  */
 public function checkAction()
 {
     $currency = Shineisp_Registry::getInstance()->Zend_Currency;
     $form = new Default_Form_DomainsinglecheckerForm(array('action' => '/domainschk/check', 'method' => 'post'));
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     $request = $this->getRequest();
     try {
         if ($request->getPost()) {
             $params = $request->getPost();
             // Delete spaces, symbols, dots, commas, spaces, etc...
             $params['name'] = Shineisp_Commons_UrlRewrites::format($params['name']);
             $available = Domains::check_availability($params['name'], $params['tld']);
             $data = DomainsTlds::getAllInfo($params['tld']);
             $tldName = $data['DomainsTldsData'][0]['name'];
             // Create the domain name
             $domain = $params['name'] . "." . $tldName;
             // Domain Price
             $price = $available ? $data['registration_price'] : $data['transfer_price'];
             $taxpercent = $data['Taxes']['percentage'];
             // Format the price number
             $strprice = $currency->toCurrency($price * ($taxpercent + 100) / 100, array('currency' => Settings::findbyParam('currency')));
             // Create the message
             $mex = $available ? $translator->translate('The domain is available for registration') : $translator->translate("The domain is unavailable for registration, but if you are the domain owner, you can transfer it!");
             $this->view->form = $form;
             $this->view->results = array('available' => $available, 'name' => $params['name'], 'tld' => $params['tld'], 'price' => $strprice, 'domain' => $domain, 'mex' => $mex);
             $this->view->suggestions = $this->chktlds($params['name'], array($params['tld']));
         }
     } catch (Exception $e) {
         $this->_helper->redirector('index', 'domainschk', 'default', array('mex' => $e->getMessage(), 'status' => 'danger'));
     }
     $this->_helper->viewRenderer('result');
 }
Exemple #11
0
 /**
  * processAction
  * Update the record previously selected
  * @return unknown_type
  */
 public function processAction()
 {
     $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
     $form = $this->getForm("/admin/wiki/process");
     $request = $this->getRequest();
     // Create the buttons in the edit form
     $this->view->buttons = array(array("url" => "#", "label" => $this->translator->translate('Save'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/wiki/list", "label" => $this->translator->translate('List'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/wiki/new/", "label" => $this->translator->translate('New'), "params" => array('css' => null)));
     // Check if we have a POST request
     if (!$request->isPost()) {
         return $this->_helper->redirector('list', 'wiki', 'admin');
     }
     if ($form->isValid($request->getPost())) {
         // Get the id
         $id = $this->getRequest()->getParam('wiki_id');
         // Set the new values
         if (is_numeric($id)) {
             $this->wiki = Doctrine::getTable('Wiki')->find($id);
         } else {
             $this->wiki->creationdate = date('Y-m-d');
         }
         // Get the values posted
         $params = $form->getValues();
         $this->wiki->uri = !empty($params['uri']) ? Shineisp_Commons_UrlRewrites::format($params['uri']) : Shineisp_Commons_UrlRewrites::format($params['subject']);
         $this->wiki->subject = $params['subject'];
         $this->wiki->metadescription = $params['metadescription'];
         $this->wiki->metakeywords = $params['metakeywords'];
         $this->wiki->category_id = $params['category_id'];
         $this->wiki->language_id = $params['language_id'];
         $this->wiki->content = $params['content'];
         $this->wiki->active = $params['active'] ? 1 : 0;
         $this->wiki->isp_id = Shineisp_Registry::get('ISP')->isp_id;
         $this->wiki->save();
         $redirector->gotoUrl("/admin/wiki/edit/id/{$id}");
     } else {
         $this->view->form = $form;
         $this->view->title = $this->translator->translate("Wiki Details");
         $this->view->description = $this->translator->translate("Here you can reply to all the customers requests");
         return $this->render('applicantform');
     }
 }